This project has moved and is read-only. For the latest updates, please go here.

Alternative way to launch a jump?

Topics: Developer Forum
Aug 27, 2010 at 5:33 PM
Edited Aug 27, 2010 at 5:34 PM

Jumping... In real life, a person jumps by applying a downward force with his legs, which launches him in the air. If we do this in mid-air, we don't jump, because there's no resistance.

As I read through some topics here, most games use the following logic: "if player is standing on platform, then apply upward impulse to the player body". Now, it seems to me like this is a very conservative approach, inspired by classic platformers that didn't rely on physics engines.

So I want to do something like the following to launch a jump:


private void Jump() {
   if(jumpInterval.IsReady) {


The way I see it, it's like a contracted spring with a certain force that is suddenly released.

  • If this occurs in mid-air, nothing happens
  • If there's some small, non-solid object below the player, this object will be kicked away by the jump force, but the player won't be launched upwards
  • If there's an actual platform beneath the player, the player performs a jump that looks similar to the 'classic' jump.
  • ...

Perhaps there aren't too many advantages to this approach. But it just seems stupid to manually check what object we're standing on. It feels like the proper way to do this, which means I can make more use of the physics engine instead of improvising some specific code to handle border cases. I expect that this will help when I extend the gameplay in the future.

I'm not (yet) worrying about the other dynamics of jumping here, like in-air movement. I just want the launch to be done in this way.

So now the question: how would I implement this using FPE3? I searched the forum, but didn't find anything. I could start improvising, but perhaps someone has a better idea of how to handle this. 

Aug 29, 2010 at 2:10 AM
Edited Aug 29, 2010 at 2:14 AM

I implemented this a while ago with the same thoughts, it wasn't too difficult.

Normally my character is made up of a block for the body and a circle for the wheel, connected with a RevoluteJoint. I changed this by adding another body connected to the main block with a PrismaticJoint, and connecting the circle to it. To jump I enable PrismaticJoint's motor so that it pushes down the wheel and causes the character to jump (remember to set limits and strength).

It didn't work too well in my game because I adjust the players angle according to ground he's standing on. So if you jump when standing on a slope you go flying off in the direction the ground is pointing! This still happens a little when the player is kept upright, but not to such a noticable degree.

Aug 30, 2010 at 6:11 PM

Ok, thanks a lot!

I managed to fix it in a similar way.

I tried to do it exactly as you described it, but I couldn't get it to work. So this is what I ended up with:

  1. Player presses jump
  2. "JumpLeg" gets created: a small, invisible box that collides with everything except the player parts
  3. JumpLeg is attached to the body (not the leg) with a prismatic joint
  4. The motor of the prismatic joint pushes down the JumpLeg
  5. When the timeout is elapsed, JumpLeg gets destroyed.
  6. Repeat

It's a weird way to solve the problem, but it works remarkably well, and I will probably reuse the code for other parts of the game (e.g. a fist punch would work in a very similar way). 

I still need to make some changes so I don't recreate the object everytime and solve some minor bugs, but this seems to be the way to go.