game-developmentgame-physicsphysics

How to predict the height of a jump based on gravity and jump speed?


Alright, so I just finished with a simple tile-based physics engine, and one thing I am tweaking now is the appropriate speed, acceleration, gravity, etc. of the character.

Right now, I am having trouble determining how the relationship between Gravity and JumpSpeed affect the overall height (climax) of the jump. Here is psuedo-code for what I have:

physics loop:
{

    calculate new X position based on DeltaTime
    calculate new y position based on DeltaTime

    if holding space and standing on block then
    {
        increase vertical velocity by JumpSpeed
    {

    decrease vertical velocity by Gravity * DeltaTime
}

Alright, now say:

Gravity = 40
JumpSpeed = 10

How can I predict the maximum height of the jump?


Solution

  • Your solution, ymax=sqrt(Gravity/JumpSpeed), doesn't look right. It implies that strong gravity should increase the height of the jump, and high initial speed should decrease it. And the right-hand side of the equation has units of 1/sqrt(time), which doesn't make sense as a height. By dimensional analysis the answer must be of the form ymax=k*JumpSpeed2/Gravity.

    According to physics, the answer is

    ymax=JumpSpeed2/(2*Gravity)

    But in your simulation, it will be

    ymax=JumpSpeed2/(2*Gravity) + JumpSpeed*DeltaTime/2