Fixed Timestep Accumulator With a Spiral of Death Guard
Last updated: November 29, 2026
Quick Overview
Write the loop logic that converts variable render frame times into fixed physics steps: for each frame return how many physics ticks to run and the interpolation alpha for rendering, capping the steps per frame so a slow frame cannot snowball.
Unity
November 29, 20260
0
0 solved
Write the loop logic that converts variable render frame times into fixed physics steps: for each frame return how many physics ticks to run and the interpolation alpha for rendering, capping the steps per frame so a slow frame cannot snowball.
Unity separates Update from FixedUpdate and exposes a maximum allowed timestep for exactly this reason, so engine and gameplay interviews like to probe whether candidates understand the game loop. The interviewer checks the accumulator pattern, the cap, interpolation, and floating point care.
What the Interviewer Expects
- Explain why physics needs a fixed step (stability, determinism)
- Implement the accumulator correctly across frames
- Cap steps per frame and say what happens to the leftover time
- Compute an interpolation alpha in [0, 1) for rendering
- Discuss float drift and an integer tick alternative
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you render using alpha, and what visual artifact does skipping interpolation cause?
- What changes for a lockstep multiplayer game that needs bit-exact determinism?
- How would you implement slow motion via a time scale?
- Why might you prefer to slow the game down rather than drop backlog time?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Input: a list of frame deltas in seconds, fixed_dt (Unity's default is 0.02) and max_steps. Output per frame: (steps, alpha). Physics must advance in exact fixed_dt increments regardless of fr...
High-Level Design
Keep an accumulator of unsimulated time. Each frame add the delta, then while the accumulator holds at least one step, run a tick and subtract fixed_dt. Rendering happens between the last two physic...