Why can a character's jump height differ at 30 and 144 frames per second even when every update is scaled by delta time?
answer
- discrete steps, not continuous motion
- error depends on step size
- same inputs, different dt sequence
- fixed step gives one answer
basics
~20 sAccelerating motion advances in discrete steps whose result usually depends on their length, so each frame rate gives a different trajectory and apex. A fixed simulation timestep gives every machine identical steps and the same height.
solid answer
~50 sDelta time makes constant velocity exact, but a jump is accelerating motion: gravity changes velocity continuously while the loop only updates it at discrete instants. With the simple update rules most gameplay code uses, a step's error depends on its length, so a variable timestep produces a different sequence of steps, and a different apex, at every frame rate. In a typical velocity-then-position update a 5 m/s jump under 10 m/s squared gravity peaks near 1.17 m at 30 steps per second and near 1.23 m at 144, against an exact 1.25 m. Long steps also make collision and stiff forces less stable. The fix is a fixed timestep for the simulation: always advance by the same `dt`, say 1/60 s, however long the frame took, and render the latest state. Every machine then computes the same trajectory, and tuning done once holds everywhere.
go deeper
Recall that delta time makes steady motion frame-rate independent but that jumps and other accelerating motion still change slightly with frame rate.
Explain that discrete steps carry an error that depends on step length, and contrast variable, semi-fixed and fixed timesteps with one strength and weakness each.
Tie the choice to stability, collision tunnelling and replays, and say which systems stay on the variable frame time and which move to the fixed step.
Frame it as a project rule: which simulation runs on the fixed step, at what rate, and how that rate is protected once designers tune against it.
## The symptom A platformer is tuned on a development PC running at 144 frames per second. On a laptop at 30 frames per second, playtesters report that the character cannot quite reach a ledge that is easy on the PC. The code already multiplies everything by **delta time** (the elapsed time since the previous frame), so the obvious frame-rate bug is not the cause. ## Why delta time is not enough for a jump Delta time makes **constant-rate** change exact: `x += speed * dt` covers the same distance per second at any frame rate. A jump is not constant-rate. Gravity changes the velocity continuously, but the loop only updates velocity and position at discrete instants, once per step. Between those instants the code treats something as constant that is really changing. The **integration rule** that runs inside a step (the update formula; choosing and analysing those rules is a physics-integration subject) almost always produces an error that depends on the step length. A **variable timestep** feeds the simulation a different `dt` at every frame rate, and on one machine from frame to frame, so the trajectory differs. ## A worked example Take a jump with initial upward velocity 5 m/s and gravity 10 m/s squared. The exact apex is `v0^2 / (2*g)` = 25 / 20 = **1.25 m**. A common per-step update applies gravity to velocity first, then moves by the new velocity: ```pseudocode velocity = velocity - g * dt height = height + velocity * dt ``` Summing these steps until velocity stops being positive gives an apex of about `v0^2 / (2*g) - v0 * dt / 2`: | Steps per second | dt | Apex reached | |---|---|---| | 30 | 33.3 ms | about 1.167 m | | 60 | 16.7 ms | about 1.208 m | | 144 | 6.9 ms | about 1.233 m | The 30 frames-per-second player jumps about 6.6 cm lower than the 144 frames-per-second player. Updating position before velocity flips the sign of the error and overshoots instead, but it still depends on `dt`. A more careful rule can be exact for constant gravity alone, yet drag, springs, ground contact and per-step game logic still change with step length, and the peak falls between sampled instants differently at each rate. The height is only the visible part. A variable step also changes: - **collision outcomes** - a long step can carry a fast object past a thin platform edge it would hit with short steps; - **stability** - stiff springs and constraints that are stable at a short step can blow up at a long one; - **reproducibility** - a replay or a networked client fed the same inputs takes different steps and drifts. ## Three loop shapes | Timestep | How it advances | Strength | Weakness | |---|---|---|---| | **Variable** | one update per frame with the measured `dt` | simple, smooth, no extra machinery | results depend on frame rate; long frames destabilise physics | | **Semi-fixed** | splits a long frame into steps no longer than a maximum, plus one shorter step for the remainder | caps the worst step length | steps still vary, so results are not identical across machines | | **Fixed** | always advances by the same `dt`, running zero, one or several steps per frame | identical steps everywhere, tuning holds, replays and lockstep become possible | needs an accumulator and, for smooth motion, render interpolation | Most engines run at least physics, and often all gameplay simulation, on a **fixed timestep**, while camera smoothing, UI and purely visual effects stay on the variable frame `dt`. The fixed rate is a project choice; values such as 50 or 60 steps per second are common, but no rate is universal. ## What a fixed step gives and what it does not With a fixed step: 1. The jump follows exactly the same sequence of states on every machine, so a ledge tuned once is reachable everywhere. 2. Designers tune against the real discrete behaviour rather than an idealised continuous one. 3. Recorded inputs can be replayed step by step. It does not on its own guarantee **bit-identical** results across different CPUs or compilers; floating-point consistency is a separate problem. And it introduces a new one: frames and steps no longer line up one to one, so the loop needs an **accumulator** to decide how many steps to run each frame, and interpolation to avoid visible stutter. ## How to explain it in an interview - State that delta time fixes constant rates, not accelerating ones. - Give the mechanism: discrete steps whose error depends on step length. - Name the fix: a fixed simulation timestep, with variable `dt` kept for presentation. - Mention the cost: an accumulator and interpolation.
- Would switching to a more accurate update rule inside each step remove the need for a fixed timestep?No. A more accurate rule shrinks the difference between frame rates, and can even be exact for constant gravity alone, but drag, springs, contacts and per-step game logic still depend on step length. Collision outcomes and stability limits change with it too. Only taking identical steps on every machine gives identical results, so the fixed timestep is still needed when consistency matters.
- What is a semi-fixed timestep, and when would you choose it over a fixed one?A semi-fixed loop breaks a long frame into steps no longer than a chosen maximum, plus a shorter final step for the remainder. It caps the worst-case step, so physics stays stable after a slow frame, and it needs no interpolation. It still produces different step sequences on different machines, so it suits single-player games that do not need replays or lockstep networking.
- Multiplying by delta time makes every motion identical at any frame rate
- A higher-order update rule makes the timestep irrelevant
- A fixed timestep means the game must render at a fixed frame rate
- A fixed timestep alone guarantees bit-identical results across CPUs
- Jump height differences come from input polling, not the step