Delta time explained: why your game runs faster on some computers
A classic beginner bug: your character moves at the perfect speed on your PC but zooms around on a faster machine (or crawls on a slower one). The fix is understanding delta time.
The problem
If you move a character 5 units every frame, then at 60 fps it moves 300 units per second, but at 144 fps it moves 720. Movement is tied to frame rate.
What delta time is
Delta time (often dt or deltaTime) is the time elapsed since the last frame, usually in seconds. Multiply movement by it:
position += speed * deltaTime
Now "speed" means units per second, regardless of frame rate.
Where to use it
- Movement and rotation
- Timers and cooldowns
- Animations and interpolation you write yourself
- Acceleration and gravity (carefully)
Where to be careful
- Physics: most engines run physics on a fixed timestep (e.g. Unity's FixedUpdate, Godot's _physics_process). Use the fixed delta there, not the frame delta.
- Lerp smoothing:
lerp(a, b, 0.1)every frame is frame-rate dependent even if you multiply by delta in the naive way. Exponential decay formulas are a more correct approach. - Large spikes: a long frame (e.g. after loading) can produce a huge delta and teleport objects. Clamp delta to a maximum.
- Pause and slow motion: a time scale value multiplied into delta makes these easy.
Fixed vs variable timestep
Many games combine both: variable timestep for rendering and visuals, fixed for physics and gameplay logic that needs determinism.
Did you run into this bug when you started? How do you handle frame-rate independence for smoothing and camera follow?
Comments · 4
Multiply every movement by delta time and your speeds will be in units per second rather than per frame. Skip that step and a 144Hz monitor turns your game into a rocket.
I ran into this in my first game and spent an hour wondering why it behaved differently on my laptop. This is the clearest explanation I've read.
Does physics need a fixed timestep instead of variable delta time? I keep seeing people mention that.
Often yes. Physics tends to be more stable with a fixed timestep, with variable delta time used for rendering and movement that doesn't need determinism.