0 Favourites

Platformer and exact jump heights

  • 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?

  • 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
  • or you could use the formulas at the end of this topic message: 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)

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Aphrodite, accuracy is pretty perfect. It seems to me that jumping is now frame independend. (latest stable release)

    (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)

  • 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)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)