Deriving the mathematics of jumping physics, Part 1 of ?

This is a rough draft of the first part of a chapter of a book I’ll probably never write. It’s obviously not done yet (needs lots more pictures) but I felt like publishing it anyway.

[Blah blah blah blah blah jumping is important because GAMES, blah blah.]

We’ll start by looking strictly at jumping strictly as a case of projectile physics.

This graph represents our position over time as we jump, peak, and land. We can immediately identify four useful variables which we would like to know:

  • h: The maximum peak height of our jump in units
  • d: The duration from when we jump until we reach the peak in seconds
  • s: Our initial upward velocity when we jump in units per second
  • g: Our acceleration due to gravity pulling us back down in units per second squared

As long as we model our jump as a projectile physics problem, these four variables completely define the motion of a jump. (In fact, as we will see later, only the initial upward velocity s and the downward acceleration constant g are necessary to model the jump, but the other properties help us understand how to reach those two.) A future post will deal with the case of variable-height jumps, in which the player can jump higher by keeping the button held down longer, but for now, we will proceed with a model in which pressing the jump button immediately applies an upward velocity, and a constant gravitational acceleration pulls us back down.

I won’t go into too much detail regarding integration (that would be for a much later post), but in general you should be familiar with Euler integration:

Position = Position + (Velocity * DeltaTime)
Velocity = Velocity + (Accleration * DeltaTime)

I’ll gloss very briefly over some calculus here, as well.

We start with our acceleration, which is constant over time:


Integrate with respect to time to find velocity:

v = ∫ a dt = at + v0

And integrate once more with respect to time to find position:

p = ∫ at + v0 dt = ½at² + v0t + p0

Now we can identify a few constants:

  • We start our jump from a height of zero:

    p0 = 0

  • Our position at time d (peak of jump) is our height constant h:

    pd = h

  • Our initial vertical velocity is our jump speed constant s:

    v0 = s

  • Our vertical velocity at time d (peak of jump) is zero:

    vd = 0

  • Our acceleration is the gravitational constant at all times:

    a = g

We can now rewrite our velocity equation in terms of our constants:

v = at + v0
v = gt + s

And also our position equation:

p = ½at² + v0t + p0
p = ½gt² + st

Next, we can solve for velocity and position at time d in order to find equations that show the relationships among our constants. Given:

v = gt + s
vd = 0

We can see:

gd + s = 0

And this gives us:

s = -gd
d = -s/g
g = -s/d


p = ½gt² + st
pd = h

We can see:

½gd² + st = h

Substituting for g from above gives us:

½(-s/d)d² + sd = h

And this gives us another set of equations relating our constants:

h = sd/2
s = 2h/d
d = 2h/s

In fact, we can now relate any of our four constants to any other two constants. (TODO: Add the full list of 12(?) equations here.)

This gives us the flexibility to define any two constants and derive the remainder from these two. Defining the jump height constant h is a no-brainer. Defining g, s, or even d is a little less intuitive. But what we can do instead is introduce another couple of movement-related constants to help us derive these:

  • m: Lateral movement speed in units per second
  • x: Lateral distance traveled while jumping in units

In an actual game scenario, we might have a range of speeds from walking to running. In this case, since we will be using the lateral speed to help derive jump constants based on the distance traveled during a jump, using the fastest speed available to the player probably makes the most sense here.

Given these properties, we can derive our total jump duration, and from that, the duration to the peak:

2d = x/m
d = x/2m

This gives us another battery of equations to derive our unknown constants from our known. (TODO: Add the full list of 60(?) equations here.)

In practical coding terms, we don’t really care about many of these constants. The designer-friendly properties like h and x would never appear in the code except as an intermediate in deriving the constants we do care about. What we should expect to use in the code on a frame-by-frame basis are:

  • g: We will apply this constant vertical acceleration to our velocity every frame
  • s: We will set our vertical velocity to this on the frame that we begin jumping
  • m: We will set (or clamp) our lateral velocity to this while running

So our goal should be to find these constants using whichever set of tunable constants we initially choose. A practical example would be to choose h, m, and x, and then derive g and s as follows:

d = x/2m


s = 2h/d
s = 4hm/x


g = -s/d
g = (-4hm/x) / (x/2m)
g = -8hm²/x²

One thought on “Deriving the mathematics of jumping physics, Part 1 of ?

Leave a Reply