- Home /
Double Jump Physics
Hello everyone,
Can someone please explain double jump physics to me? I am trying to code this as a special suit in my game. It works, but I'm not sure if it's working as expected. The double jump height is different depending on when the double jump is initiated. If double jump is initiated before the peak of the first jump, the character jumps much higher than if double jump is initiated when the character is at the peak of or falling from the first jump.
Am I making sense? Could someone explain the physics to me and what the proper physics should be?
You can try it out on this demo I've been working on (a sidescrolling endless runner): http://fanqu.net/demo/. Click play to start the game, left mouse click or spacebar to jump. If you jump twice really quickly, you can see the cube jumps really high. But if you jump once, then wait for the player to start falling and try to jump again, you can see the second jump is much smaller.
Thanks all.
I found an article after some better google keyword searching. The article is pretty helpful describing a few jumping techniques.
Answer by Phillipus · Jul 15, 2015 at 01:17 AM
If you are causing the character to jump by adding force to the rigidbody, then the problem is pretty simple. When the character is after the peak of the jump, if you add an upward force to the character then the force first counteracts the downward velocity, then pushes the character upwards. If the character is before the peak then the force is simply added to their current velocity, resulting in a higher jump.
One possible solution to this problem would be to check the character's velocity before adding force and accounting for the difference, or setting the velocity to 0 before adding the force. Although both would result in the same outcome, the latter is probably easier to implement.
Your answer
Follow this Question
Related Questions
How to make correct double jump with collor changing? 0 Answers
Double-jump mechanic has an initially high jump 1 Answer
2D 360 degress platformer example needed 0 Answers
Rigidbody2D.velocity affects the y-axis, but not the x-axis. 1 Answer
Can I make physics engine speed dependent on frame rate? 2 Answers