Jump to specific position (using platform behavior)

Get help using Construct 2

Post » Fri May 29, 2015 5:33 pm

How can I get an object using the platform behavior to jump to a specific position? i.e. an enemy jumps from right side of the screen to the left or jumps from the right or left side to the middle.

There's a parabola example around here somewhere that can do this well, but I just wanted to see if it can be done with the platform behavior and minimal variables because I'll be using it often and with a number of different objects.
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Fri May 29, 2015 5:59 pm

I guess you would have to use some math to calculate the vectorX and vectorY of the platform behaviour..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat May 30, 2015 4:14 am

Well yeah.
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Sat May 30, 2015 6:29 am

To get the launch speed you can do the following. Be sure to set deceleration to 0.

Vector x = (x1-x0)/t
Vector y = (y1-y0)/t-0.5*gravity*t

X1,y1 is the destination
X0, y0 is the start
Gravity is whatever the behavior's Gravity is
T is how long you want the jump to take in seconds.

Overall the math should be the same as in that example you're referring to. The actual path will vary a bit due to the variable delta time but it should be pretty consistent.
B
91
S
31
G
102
Posts: 5,234
Reputation: 67,254

Post » Sat May 30, 2015 12:16 pm

Great, @R0J0hound.

I had a similar problem. ^^
B
38
S
9
G
3
Posts: 257
Reputation: 4,316

Post » Sat May 30, 2015 5:22 pm

Thanks man I'll try it out soon :)
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], newday198913, rotacak and 5 guests