Video summary
Math for Game Programmers: Building a Better Jump
Main summary
Key takeaways
Main Ideas
- Design jumps around player-facing goals, not arbitrary physics constants. Specify what the jump should do—such as how high it rises and how far it travels—then calculate the physics parameters needed to achieve it. This makes tuning easier and reduces the risk of disrupting level layouts.
- A basic jump follows a parabolic path. Assuming constant downward gravity and ignoring drag, acceleration is constant, velocity changes linearly over time, and position follows a parabola.
- Ascent and descent are symmetric under constant gravity. The time from takeoff to the peak equals the time from the peak back to the starting height. At the peak, vertical velocity is zero. On landing, vertical velocity has the same magnitude as at takeoff, but in the opposite direction.
- Keep horizontal and vertical movement independent. Jumping should add vertical velocity without canceling the character’s existing sideways movement. This applies in both 2D and 3D games.
- Use physics as a foundation, not a restriction. Changing gravity or using different trajectory segments can make jumps feel distinctive while preserving designer-defined height and distance goals.
Deriving a Jump from Desired Height and Timing
For a straight-up jump, define:
- H: desired jump height
- Tₕ: time from takeoff to the peak
- g: downward gravitational acceleration
- v₀: initial upward velocity
With upward treated as positive, the required values are:
- Initial velocity: (v₀ = 2H/Tₕ)
- Gravity: (g = -2H/Tₕ²)
The full jump back to the starting height takes 2Tₕ. These equations let a designer choose the height and time to peak, then calculate the initial velocity and gravity.
Including Horizontal Distance
To design a jump through space, also specify:
- xₕ: horizontal distance covered by the time the character reaches the peak
- vₓ: horizontal movement speed
The time to the peak is Tₕ = xₕ/vₓ. Substituting this into the vertical-jump equations gives:
- Initial vertical velocity: (v₀ = 2H vₓ/xₕ)
- Gravity: (g = -2H vₓ²/xₕ²)
This lets designers define a jump using its height, horizontal distance, and sideways speed rather than guessing gravity and jump velocity.
Shaping the Jump’s Feel
- Faster falling: Use one curve for ascent and a steeper curve for descent. When vertical velocity changes from positive to negative at the peak, switch to stronger downward gravity.
- Variable-height jumps: Treat the maximum jump as the default. If the player releases the jump button before reaching the peak, increase gravity so the character reaches a lower peak sooner. A minimum jump height can ensure that even a brief button press produces a meaningful jump.
- Combined jump behaviors: After an early button release, the game can restore normal gravity at the peak or retain stronger gravity for a quicker fall. Faster falling can also be combined with variable-height jumping.
- Double or multi-jumps: Treat each stage as its own parabolic segment, with its own height, distance, initial velocity, and gravity.
These techniques depart from real-world constant-gravity motion but give designers more control over weight, responsiveness, and character-specific feel.
Applying Gravity Over Time
The talk compares several approaches to updating a character’s state:
- Euler integration: Update position from velocity and elapsed time, then update velocity from acceleration and elapsed time. It is simple, but can be unstable or frame-rate-sensitive.
- Runge–Kutta methods, such as RK4: More elaborate methods that may be unnecessary when the motion is mostly projectile motion.
- Simplified velocity Verlet: For constant acceleration, update position using position += velocity × Δt + ½ × acceleration × Δt², then update velocity using velocity += acceleration × Δt. This matches the projectile-motion equation for constant acceleration.
When gravity changes deliberately—for example, at the jump’s peak—the simplified update introduces a small one-time error. Pittman reports that in one of his games it was about half a pixel and did not accumulate over time, making the method a practical alternative to Euler integration for this use case.
Examples and References
- Super Mario Bros.: Cited as an example of a jump that becomes heavier as the character falls, including a sudden increase in gravity after the peak.
- Super Meat Boy: Mentioned in the Q&A as an example of distinctive, fluid movement that works together with wall interactions and wall jumping.
- You Have to Win the Game and Gunmetal Arcadia: Pittman’s games, which he says use the principles discussed.
Speakers and Sources
- Speaker: Kyle Pittman, Minor Key Games
- Audience questioner: Unidentified; asks about other examples of good or bad jumping
- Works and games referenced: Game Feel by Steve Swink; the Gaffer On Games article “Integration Basics”; Super Mario Bros.; Super Meat Boy; You Have to Win the Game; and Gunmetal Arcadia
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.