How do I apply gravity in z axis rather than y?

Get help using Construct 2

Post » Sun Jan 04, 2015 7:19 pm

Hi Guys,

I want to be able to through missiles on the flat ground, what I mean is how can I apply physics like the shown image? is it possible? in the other word is is possible to apply the gravity toward z axis? rather than y axis? or since it is a 2D game engine that is not possible?
You do not have the required permissions to view the files attached to this post.
B
5
S
1
Posts: 35
Reputation: 447

Post » Sun Jan 04, 2015 7:49 pm

Well, we are looking at a 2D plane so it's going to work on the Y axis anyway. What you could do is add an instance variable, say SpawnY and then add a check when Sprite.Y is > SpawnY - you know it has hit ground and should explode/damage other things, etc.

Than just make your projectile move in an arch by using whatever - bullet and rotate behaviour or bullet + subtracting from y every tick or just making the movement yourself.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Sun Jan 04, 2015 8:35 pm

You might have to work on some projectile equations/math to get it working the way you intend.
moving along the x and y axis at a constant rate, while offsetting the missile in the y axis.
B
45
S
21
G
65
Posts: 1,118
Reputation: 38,227

Post » Mon Jan 05, 2015 2:46 am

Just set angle of motion, gravity, speed and acceleration for any object with bullet (make sure you enable it at time of created) and it would work like you wanted.

No need for equations or variables.

Set "Set Sprite Angle" to Yes so the object would automatically angle according to its "angle of motion".

And yes, I have made it to work like that. It's simple.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Mon Jan 05, 2015 4:33 pm

Many thanks All for all your suggestions.
sgn15 is there any chance you could make a very simple capx example ?

Many thanks again.
B
5
S
1
Posts: 35
Reputation: 447

Post » Mon Jan 05, 2015 9:42 pm

This example may help:
viewtopic.php?f=147&t=71476&p=601468&hilit=projectile#p601468

Z is just the y distance from the shadow on the ground.
B
92
S
32
G
109
Posts: 5,294
Reputation: 70,999

Post » Tue Jan 06, 2015 3:07 am

@zardaloop

I would suggest set all bullets to disabled at the start (bullet properties in sidebar) and enable them using events so you're sure there's nothing flying around when you don't need it. Of course you need at least 1 instance of the bullet object (or rocket in your pic) either in this layout or somewhere else in your project.

Image

You can adjust all bullet parameters to make it arc even more

Angle of motion is different when facing left or right (you should know how to count degrees)
start at 0 degrees at right
counterclockwise is adding 1 degree
clockwise is adding -1 degree
360 degrees in 1 full circle
360 degrees same as 0 degrees
research on this if you're not a numbers person

Set Bullet's "Set Angle" to Yes (bullet properties in sidebar) to angle the sprite of the rocket similar to angle of motion

Use the @ sign next to my name (like I did to your name in this post) and I will get a notification and I will reply to you again.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Wed Jan 07, 2015 9:24 am

Many thanks Guys,

I have ended up using @R0J0hound solution which is exactly what I needed :D

http://dl.dropbox.com/u/5426011/example ... ctile.capx

Many thanks again for all your helps.

Cheers
B
5
S
1
Posts: 35
Reputation: 447


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, ratboy3, yolkgames and 33 guests