[Solved] - Physics - Double Jump Scenario Issue



I'm new here =)
This looks like a great community!!

I have a question regarding this:
"physics_apply_local_impulse(0, 0, 0, -5 );"

The Scenario
i have the player object sitting on the ground, when hitting "Space" i run this command to jump using "physics_apply_local_impulse(0, 0, 0, -5 );".

I want the player to be able to also jump in mid air (like a double jump), and i want the second jump to make the player jump the same height\distance as the one from the ground.

so if from the ground the jump is 10cm, doesn't matter when i click the jump again, even in mid air, i want to player to jump 10cm more from the current position in mid air.

The problem:
when clicking the Jump key again while in mid air, if the player is on the way down from the previous jump, then it jumps (goes up) only 1-2 cm and then keeps falling, probably because of the initial force applied to the player by the gravity while it is falling.
I read that impulse does NOT take into consideration the current object movement, and should ignore it and act the same if the object is not moving.

What am I missing?
Do I need to, before running the impulse command - somehow stop the object and mid air and have the impulse then apply on the "stationary mid air object? if yes, how?

Thanks in advance!
Last edited by a moderator:


I tried some stuff but still no solution =(
Can anyone please help?


that bit in the manual about not take into consideration just means it will apply a local force meaning say you have it push direct from the bottom feet of player up towards middle of player or where you origin is as you doing it at 0,0 then it will always apply it like that no matter what angle its at, if you didnt use local then it could be coming from any angle such as the mouse so would push it away from the mouse, so what you will have to do is calculate the gravity and convert that to the force you need, so that -5 will have to be a variable, also forces are accumulative so say your going up and only just started going up and press again you will get a boost effect as its adding to the impulse force.


If you're making a physics based platformer, I actually like the added complexity of timing the double jump.

I re-read the help file and neither one cancels momentum. Force applied a uniform push to the object. Impulse applied a push to a specific point. [Think gravity compared to a pool stick.]

So, you need to set phy_linear_velocity_y to 0 right before the impulse if you want to give your player a very specific amount of vertical energy. I'm assuming that you want to leave phy_linear_velocity_x alone so you can have various angles of horizontal movement for running, walking, and standing jumps.

Let me know if that works, it sounds right, but it is nice to have confirmation. :)


Thanks Zircher!!
"phy_linear_velocity_y = 0" was exactly what i was looking for!

worked like a charm =)
thanks again!