# Platformer and exact jump heights

Get help using Construct 2

### » Fri Oct 07, 2016 1:21 am

So I'm working on a game that runs within a platformer's rules. As expected there will be lots of platforms of different heights. How should I make an enemy/whatever that runs on Platformer behavior to jump from their level to another platform, preferably the one player is currently on? I know how to get the Y-distance between the enemy and player, but how would I make them jump just right to reach that platform?
B
22
S
7
G
4
Posts: 235
Reputation: 3,503

### » Sun Oct 09, 2016 12:21 am

Maybe you can try adjusting the enemy's jump strength and sustain values depending on the Y-distance to the player. Something like,

On Enemy about to jump
- Set Enemy jump strength to Y-distance/5
- Set Enemy jump sustain to Y-distance/10
- Enemy jump
B
61
S
25
G
19
Posts: 306
Reputation: 13,939

### » Sun Oct 09, 2016 6:47 am

or you could use the formulas at the end of this topic message: viewtopic.php?f=146&t=128434&p=905081#p905081 to adjust the jumpstrength of the ennemy relative to the height you want to achieve (I do not guarantee perfect accuracy due to how C2 works, but each time we saw it innacurate, it was slightly higher and so reached the platform anyway, except in case of a big fps drop)

JumpStrength = sqrt(2*H*Gravity) would be the formula you are looking for I think (Be sure that the H value is positive when you use it, or else you'll have a math error)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
23
G
18
Posts: 2,123
Reputation: 17,200

### » Sun Oct 09, 2016 3:30 pm

@Aphrodite, accuracy is pretty perfect. It seems to me that jumping is now frame independend. (latest stable release)

https://www.dropbox.com/s/i3h3w3lpw1idw ... .capx?dl=0

(to be honest ... i took to much time to figure that out on my own, then , when posting, i noticed you wrote the solution perfectly down already, poor me)
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Sun Oct 09, 2016 6:58 pm

@99Instances2Go I tested your capx and there is a small innacuracy compared to the formula (around 15 more pixels for a 900 pixels jump if I am not mistaking, which is about 1.7%, on Edge it seems to be varying more sometimes, but that may be my computer), I agree it is not that big but we do not know how accurate the OP wanted to predict it, I am also in the latest stable.

We actually discussed that difference in another topic and ashley suggested a solution to the issue but does not seem to have it implemented yet.

(also sorry that you had to take time to figure out the formulas, I know those are not that easy to calculate)
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
23
G
18
Posts: 2,123
Reputation: 17,200

Return to How do I....?

### Who is online

Users browsing this forum: IGDev, Metathronos and 10 guests