# Jumping

This topic is 3940 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

How can I make a realistic looking jump like the ones from Super Mario Bros? Is there a formula to use? What do I need to tamper with the X and Y axis so that I can make realistic jumps?

##### Share on other sites
You could be a bit more specific but I'll assume your question as about making jumps that are like a smooth parabolic curve instead of a squarish up-then-down constant velocity approach.

If so, then the answer is easy : You need to have a vertical speed variable. Upon jumping, you set this variable to, say... 10 units. At each frame, you increase the character's Y-position by the vertical speed variable and decrease that vertical speed variable. Eventually, the vertical speed variable will be negative so your guy will come down. You might want to set a maximum falling speed for collision detection's sake.

This is "physically accurate" because the gravity in m/s² affects your speed in m/s which in turn affects your position in meters.

Hope this helps

##### Share on other sites
Quote:
 Original post by TrillianIf so, then the answer is easy : You need to have a vertical speed variable. Upon jumping, you set this variable to, say... 10 units. At each frame, you increase the character's Y-position by the vertical speed variable and decrease that vertical speed variable. Eventually, the vertical speed variable will be negative so your guy will come down. You might want to set a maximum falling speed for collision detection's sake.This is "physically accurate" because the gravity in m/s² affects your speed in m/s which in turn affects your position in meters.

Actually, it is nearly physically accurate. The equations are:
    y = y0 + v0t + ½at2    v = at        y is the current height    y0 is the starting height    v0 is the starting vertical speed    t is the amount of time that has passed since the jump started    a is the acceleration constant (gravity is -9.8 m/s2)    v is the current velocity

It is frequently important to use the correct equations in platform games because the behavior of the simplified ones vary depending on the framerate, and a jump that can be made on one computer might be impossible on another.

(copy-paste)