---
id: "fixed-timestep-integration"
title: "Fixed timestep game loop and integration"
aliases: [fix your timestep, semi-fixed timestep, accumulator loop]
domain: "simulation"
stage: "simulation"
realtime: "realtime"
platforms: [cpu, webgl2, webgpu, desktop-gpu, unity, unreal, godot, python]
year_introduced: 2004
inputs: [particles]
outputs: [particles, animation]
style: "both"
dynamic: "dynamic"
cost: "cheap"
authority: "Fiedler"
url: "https://texelatlas.vercel.app/t/fixed-timestep-integration/"
sources_verified_at: "2026-11-29"
---
# Fixed timestep game loop and integration (Fiedler)

> Advance physics in constant-size steps from a time accumulator, then interpolate rendered state between the last two steps so simulation stays deterministic while display frame rate varies.

## Reach for it when

- physics behaves differently at different frame rates
- simulation explodes when a frame takes too long
- motion judders even though physics runs at fixed rate
- need deterministic stepping so replays match exactly

## How it works

The loop measures wall-clock time per rendered frame, clamps it to a maximum (to avoid the spiral of death where slow frames demand more steps that make the next frame slower), and adds it to an accumulator. While the accumulator holds at least one step dt, the simulation advances by exactly dt and dt is subtracted. Because every step has identical length, results do not depend on frame rate, integrators such as semi-implicit Euler, Verlet or RK4 keep their stability limits, and recorded inputs replay identically. After stepping, the leftover fraction alpha = accumulator / dt describes how far the display time is between the previous and current states. The renderer blends those two stored states with alpha, which removes the temporal stutter that a fixed step otherwise causes when it does not divide the display rate. Variants run several substeps inside each step, or drive the simulation from the audio or network clock.

## When to use it

Choose it for any physics, particle or gameplay simulation where stability, determinism or networking replay matter. Prefer plain variable-dt stepping only for purely visual effects that tolerate drift, such as small [Particle systems](https://texelatlas.vercel.app/t/particle-systems.md) updates. It underpins [Verlet integration with relaxation constraints](https://texelatlas.vercel.app/t/verlet-integration-constraints.md), [Extended Position-Based Dynamics](https://texelatlas.vercel.app/t/xpbd.md), [Sequential impulses (rigid bodies)](https://texelatlas.vercel.app/t/sequential-impulses.md) and [Position Based Dynamics](https://texelatlas.vercel.app/t/position-based-dynamics.md), whose stiffness and iteration counts are tuned for a fixed dt. Use substepping (as in [Extended Position-Based Dynamics](https://texelatlas.vercel.app/t/xpbd.md) small-step solvers) instead of a smaller global step when only the solver needs more resolution.

## Cost

cheap — Overhead is negligible; total cost is steps per frame times the cost of one simulation step.

## Failure modes

- Spiral of death when a step costs more than dt of real time, unless frame time is clamped
- Temporal aliasing and judder if the render state is not interpolated and dt does not divide the display period
- Interpolating between states lags rendering by up to one step, which matters for input latency in competitive games
- Interpolation of rotations or wrapped values needs slerp or angle handling, not component-wise lerp
- Floating-point accumulation in the accumulator drifts if stored as float seconds over long sessions

## Engine support

- babylonjs: builtin — `physicsEngine.setTimeStep(1 / 60) and physicsEngine.setSubTimeStep(ms) in Physics v2` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/core/src/Physics/v2/physicsEngine.ts, checked 2026-12-01)
- godot: builtin — `Node._physics_process(delta); Project Settings > Physics > Common > Physics Ticks Per Second` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/ProjectSettings.xml, checked 2026-12-01) — Fixed-rate physics tick; physics_jitter_fix controls frame-time smoothing.
- unity: builtin — `Project Settings > Time > Fixed Timestep; MonoBehaviour.FixedUpdate` (evidence: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Time-fixedDeltaTime.html, checked 2026-12-01)
- unreal: builtin — `Project Settings > Physics > Substepping` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/physics-sub-stepping-in-unreal-engine, checked 2026-12-01) — Physics sub-stepping into fixed steps; the frame loop itself is variable-rate.

## Dataflow

- Inputs: particles
- Outputs: particles, animation
- Platforms: cpu, webgl2, webgpu, desktop-gpu, unity, unreal, godot, python

## Presets

### 60 Hz physics step with frame clamp (json-params; parameter preset)

```json
{
  "dt": 0.016667,
  "max_frame_time": 0.25,
  "max_steps_per_frame": 5,
  "interpolate_render_state": true
}
```

Attribution: written for this index

## Combines with

- [Quaternion slerp rotation interpolation](https://texelatlas.vercel.app/t/quaternion-slerp-interpolation.md): Render-state interpolation between the last two fixed steps blends orientations with slerp rather than component-wise lerp.
- [Extended Position-Based Dynamics](https://texelatlas.vercel.app/t/xpbd.md): A fixed dt makes constraint compliance and iteration counts mean the same thing every frame.

## Sources

1. [primary] Glenn Fiedler Fix Your Timestep!. gafferongames.com. https://gafferongames.com/post/fix_your_timestep (verified via http on 2026-11-29)
2. [tutorial] Glenn Fiedler Integration Basics. gafferongames.com. https://gafferongames.com/post/integration_basics (verified via http on 2026-11-29)

## Cite this entry

Texel. "Fixed timestep game loop and integration." https://texelatlas.vercel.app/t/fixed-timestep-integration/ (accessed 2026-12-01).
