Platformer and exact jump heights

Get help using Construct 2

Post » 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
21
S
7
G
4
Posts: 231
Reputation: 3,470

Post » 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
50
S
23
G
17
Posts: 291
Reputation: 12,432

Post » 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
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » 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
28
Posts: 2,462
Reputation: 20,888

Post » 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
52
S
22
G
18
Posts: 2,122
Reputation: 17,093


Return to How do I....?

Who is online

Users browsing this forum: Cha0tiXGamer, ezgaming420, plinkie and 11 guests