When beginning game development in Unity, almost every engineer commits a classic rule of thumb to memory: “The Update loop runs every frame depending on render speed, while FixedUpdate runs at fixed 0.02-second intervals for physics calculations”.
This explanation is intuitive and easy to remember. But looking deeper into the architectural layers beneath the Unity Engine, it introduces a dangerous misconception: many developers believe that FixedUpdate possesses its own independent clock running concurrently on a background thread, or that it executes exactly once every render frame.
In reality, that is not how the engine works. FixedUpdate has no separate thread. It runs sequentially on the Main Thread, immediately before Update is called. Its rhythm is governed by an internal time-tracking machine known as the Time Accumulator.
Failing to understand the mechanics of this accumulator can turn a minor frame-rate hitch into a catastrophic positive feedback loop: the Spiral of Death, converting a transient 50ms spike into a total game freeze where frame rate plunges to zero.
1. The Time Accumulator Inside the Unity PlayerLoop
To understand why FixedUpdate invocations fluctuate between zero and dozens of iterations within a single render frame, we must dissect time progression inside Unity’s PlayerLoop:
flowchart LR
subgraph INPUT["1. Frame Time Influx"]
direction TB
I1["Elapsed delta time scaled by timeScale"]
I2["Accumulated into Time Accumulator"]
I1 --> I2
end
subgraph LOOP["2. Physics Loop: Main Thread"]
direction TB
L1["Check: accumulator >= fixedDeltaTime?"]
L2["Execute FixedUpdate & PhysX Step"]
L3["Subtract: accumulator -= fixedDeltaTime"]
L1 -->|"Every 20ms"| L2 --> L3 --> L1
end
subgraph RENDER["3. Graphic Render Phase"]
direction TB
R1["accumulator < fixedDeltaTime"]
R2["Execute Update & LateUpdate"]
R3["Submit draw calls to GPU"]
R1 --> R2 --> R3
end
INPUT --> LOOP
LOOP -->|"Accumulated time exhausted"| RENDER
The Accumulator Pipeline
Inside Unity’s native C++ core, the engine maintains an internal floating-point accumulator representing unprocessed physical time:
- Beginning of Each Render Frame: The engine measures elapsed real time since the prior frame (scaled by
Time.timeScaleand clamped bymaximumDeltaTime), adding this value to theTime Accumulator. If the game is paused (Time.timeScale = 0), zero time is added and the physics loop remains dormant. - Checking Physics Timestep Thresholds: As long as the accumulated balance in the
Accumulatorremains greater than or equal toTime.fixedDeltaTime(default0.02s, corresponding to 50Hz):- Unity calls
FixedUpdate()across all active MonoBehaviours. - The engine steps the PhysX simulation forward (
Physics.Simulate). - The engine decrements
Time.fixedDeltaTimefrom theAccumulator.
- Unity calls
- Exiting the Physics Phase: When remaining accumulated time drops below
0.02s, the Main Thread leaves the physics phase to executeUpdate(),LateUpdate(), and submit draw calls to the GPU.
2. Consequences of Frame Rate Variance: 0 to N Steps Per Frame
From this accumulator mechanism, we arrive at an essential realization: The number of FixedUpdate calls per render frame depends entirely on the duration of that frame:
- On a 120 FPS High-Refresh Display:
Each frame duration is approximately8.33ms. When this duration enters the accumulator, it fails to reach the20ms(0.02s) threshold.
-> Outcome: During that frame,FixedUpdateruns exactly 0 times! Visuals render smoothly, but physics state does not advance. - At Standard 60 FPS:
Frame duration is16.66ms. Because real time does not divide evenly by 20ms, the engine alternates: some frames execute 0 physics steps, while others execute 1, keeping simulation time aligned with real time. - During a Lag Spike (e.g., synchronous asset loading taking 60ms):
The accumulator receives60msat once. To catch up, Unity must executeFixedUpdate3 times sequentially in that single frame (60ms / 20ms = 3) before allowing that frame to render!
3. The Spiral of Death Trap
A minor lag spike resolves quickly if routines inside FixedUpdate are lightweight. But what happens if the physics calculations themselves saturate the CPU?
That is when a project enters the game loop’s most devastating failure mode: the Spiral of Death.
flowchart TD
P1["1. Physics collision spike or heavy asset load<br/>Frame time suddenly surges to 100ms"]
P2["2. Next Frame: Accumulator receives 100ms lag<br/>Unity forces 5 consecutive FixedUpdate steps"]
P3["3. Executing 5 physics steps consumes 250ms CPU<br/>Third frame receives 250ms backlog"]
P4["4. Unity forces 12 FixedUpdate iterations...<br/>CPU deadlocks, FPS drops to zero!"]
P1 --> P2 --> P3 --> P4
CLAMP["SAFETY BREAKER: Time.maximumDeltaTime<br/>• Clamps accumulated time influx to 0.1s - 0.15s<br/>• Caps maximum step iterations at 5 - 7<br/>• Sacrifices real time (slow-motion) to save Main Thread"]
P2 -.->|"Clamps if backlog breaches threshold"| CLAMP
CLAMP ==>|"Relieves Main Thread load"| SAFE["Exits loop -> Resumes Rendering"]
The Main Thread Collapse
Consider a practical action or shooter scenario:
- Frame 1: A grenade explodes into a mob of 100 physics ragdolls. Heavy collision computations cause the frame duration to surge to 100ms.
- Frame 2: The
Time Accumulatorreceives this100msbacklog. To catch up, Unity calculates:100ms / 20ms = 5. The engine forces the Main Thread to execute 5 consecutiveFixedUpdatesteps and 5 PhysX simulations! - Compounding Load: Processing 5 heavy physics steps sequentially forces Frame 2 to consume 250ms.
- Frame 3: The accumulator receives
250msof backlog. Unity calculates:250ms / 20ms = 12.5. The engine attempts to execute 12FixedUpdateiterations! - Deadlock: Each passing frame inherits compounded backlog from its predecessor. Physics iterations grow exponentially. The Main Thread is permanently trapped inside physics loops with zero time remaining to render frames. The screen freezes, audio loops, and the process stalls completely.
4. The Circuit Breaker: Time.maximumDeltaTime
To prevent the time accumulator from strangling the Main Thread, Unity engineers engineered an essential safety circuit breaker: Time.maximumDeltaTime.
How the Circuit Breaker Operates
This setting acts as a pressure relief valve:
- The default value of
Time.maximumDeltaTimein Unity is0.3333333s(approximately 1/3 of a second). - When a lag spike exceeds this threshold (for instance, a frame taking 1.5 seconds due to disk I/O), Unity clamps the time entering the accumulator, taking a maximum of
0.333sand discarding the excess. - Consequently, the maximum number of
FixedUpdateiterations in a single frame is strictly capped at:
0.333s / 0.02s = ~16 steps.
By capping iteration counts, the CPU is guaranteed to exit the physics loop after at most 16 iterations, returning control to the rendering pipeline.
The Trade-off: Temporary Slow-Motion
Engineering involves trade-offs:
- Discarding elapsed real time means game simulation time (
Time.time) drifts behind real-world clock time. - Players perceive physical simulation drifting into slow-motion during severe frame drops.
- However, this temporary slow-down is an invaluable compromise: it keeps the Main Thread alive, prevents the Spiral of Death, and allows the game to recover once CPU loads stabilize.
The default threshold of 0.333s (allowing up to 16 iterations) is excessively high for mobile hardware. Executing 16 complex collision steps inside a single frame still freezes a phone for 300ms to 500ms. For mobile projects, it is strongly recommended to reduce Time.maximumDeltaTime to 0.1s - 0.15s (capping iterations at 5 to 7 steps).
5. Production Implementation: Monitoring and Clamping
In a mobile Roguelike Swarm game simulating thousands of colliding entities, the engineering team attaches a time management script (PhysicsSafetyGuard). This script tunes maximumDeltaTime for mobile hardware while tracking physics step piling to trigger defensive load-shedding when necessary.
Production Example: PhysicsSafetyGuard
using UnityEngine;
public class PhysicsSafetyGuard : MonoBehaviour
{
[Header("Mobile Safety Thresholds")]
[Tooltip("Caps accumulated time to extinguish the Spiral of Death")]
[SerializeField] private float _customMaximumDeltaTime = 0.1f; // Max 5 steps (0.1 / 0.02)
[Header("Physics Piling Monitoring")]
[Tooltip("Number of FixedUpdate steps in a single frame that triggers a warning")]
[SerializeField] private int _warningStepThreshold = 4;
private int _fixedStepsThisFrame;
private void Awake()
{
Time.maximumDeltaTime = _customMaximumDeltaTime;
}
private void FixedUpdate()
{
_fixedStepsThisFrame++;
}
private void Update()
{
if (_fixedStepsThisFrame >= _warningStepThreshold)
{
Debug.LogWarning($"[PhysicsSafetyGuard] Frame hitch warning! This frame endured {_fixedStepsThisFrame} piled FixedUpdate steps.");
// Opportunity to shed load: throttle particle spawns, reduce physics accuracy, etc.
}
_fixedStepsThisFrame = 0;
}
}
Pure C# Simulator and Automated Unit Tests
To verify accumulator stepping and clamping algorithms without opening the Unity Editor, we build an isolated simulation engine tested via NUnit:
using NUnit.Framework;
public class TimeAccumulatorSimulator
{
public float Accumulator { get; private set; }
public int LastStepCount { get; private set; }
public int StepFrame(float unscaledDeltaTime, float fixedDeltaTime, float maximumDeltaTime)
{
// 1. Apply circuit breaker: clamp elapsed delta time
float clampedDeltaTime = unscaledDeltaTime > maximumDeltaTime ? maximumDeltaTime : unscaledDeltaTime;
// 2. Deposit into accumulator
Accumulator += clampedDeltaTime;
// 3. Execute physics loop
LastStepCount = 0;
while (Accumulator >= fixedDeltaTime)
{
LastStepCount++;
Accumulator -= fixedDeltaTime;
}
return LastStepCount;
}
}
[TestFixture]
public class TimeAccumulatorEngineTests
{
private TimeAccumulatorSimulator _simulator;
private const float FixedDeltaTime50Hz = 0.02f;
[SetUp]
public void Setup()
{
_simulator = new TimeAccumulatorSimulator();
}
[Test]
public void StepFrame_At120Fps_ExecutesZeroFixedUpdatesInFirstFrame()
{
// At 120 FPS, frame time is ~8.33ms, insufficient to trigger 20ms physics step
float frameTime120Fps = 0.008333f;
int steps = _simulator.StepFrame(frameTime120Fps, FixedDeltaTime50Hz, 0.333f);
Assert.AreEqual(0, steps, "At 120 FPS, the first frame has insufficient accumulated time, executing 0 FixedUpdates.");
Assert.AreEqual(0.008333f, _simulator.Accumulator, 0.0001f);
}
[Test]
public void StepFrame_At60Fps_AlternatesIterationsToMatchRealTime()
{
float frameTime60Fps = 0.016666f;
// Frame 1: Accumulates 16.66ms (< 20ms) -> 0 steps
int step1 = _simulator.StepFrame(frameTime60Fps, FixedDeltaTime50Hz, 0.333f);
Assert.AreEqual(0, step1);
// Frame 2: Accumulates additional 16.66ms (Total 33.32ms >= 20ms) -> 1 step, leaving 13.32ms
int step2 = _simulator.StepFrame(frameTime60Fps, FixedDeltaTime50Hz, 0.333f);
Assert.AreEqual(1, step2);
Assert.AreEqual(0.013332f, _simulator.Accumulator, 0.0001f);
}
[Test]
public void StepFrame_WhenSpikeOccurs_WithoutClamp_GeneratesDangerousMultipleSteps()
{
// 100ms lag spike without clamping
float lagSpike = 0.10f;
int steps = _simulator.StepFrame(lagSpike, FixedDeltaTime50Hz, 1.0f);
// 100ms / 20ms = 5 sequential steps
Assert.AreEqual(5, steps, "A 100ms frame hitch forces 5 consecutive FixedUpdate steps.");
Assert.AreEqual(0.0f, _simulator.Accumulator, 0.0001f);
}
[Test]
public void StepFrame_WhenSpikeExceedsMaxDeltaTime_ClampsIterationsSuccessfully()
{
// 500ms lag spike protected by 100ms maximumDeltaTime clamp
float massiveLag = 0.50f;
float maxDeltaTime = 0.10f;
int steps = _simulator.StepFrame(massiveLag, FixedDeltaTime50Hz, maxDeltaTime);
// 500ms is clamped to 100ms -> strictly 5 steps instead of 25
Assert.AreEqual(5, steps, "maximumDeltaTime clamps elapsed time, extinguishing the Spiral of Death.");
}
}
6. Architectural Trade-off Matrix
| Criteria | Default Threshold (0.333s) | Mobile Clamped (0.1s - 0.15s) |
|---|---|---|
| Max Accumulated Steps | 16 to 17 iterations per frame | Capped at 5 to 7 iterations |
| CPU Burden During Spikes | Severe; freezes hardware for 300-500ms | Lightweight; CPU exits physics phase quickly |
| Risk of Spiral of Death | Moderate under heavy PhysX loads | Near Zero; iteration cap prevents lockup |
| Simulation Slow-Down Drift | Lower; attempts to catch up to real time | Higher slow-motion visibility during hitches |
| Spatial Physics Fidelity | Compensates all steps | Sacrifices transient steps to protect rendering |
| Optimal Project Fit | High-end PC/Console with multi-core CPUs | Mobile titles, swarms, physics-heavy games |
7. Production Takeaways
- FixedUpdate is Not Concurrent: Never treat
FixedUpdateas a background thread. It executes sequentially on the Main Thread. Heavy calculations insideFixedUpdateamplify lag exponentially when frame rates dip. - Never Read Raw Input Directly in FixedUpdate: On 90Hz-120Hz displays,
FixedUpdateskips execution on select frames. If a player taps a button during a skipped frame viaInput.GetKeyDown, the input is dropped. Always capture inputs insideUpdateand pass flags toFixedUpdate. - Lower
Time.maximumDeltaTimeon Mobile: For mobile projects featuring complex physics, reducing this threshold from0.333sdown to0.1sis the most effective safety net against unrecoverable screen freezes. - Zero Allocations Inside FixedUpdate: Because
FixedUpdatecan run multiple times per render frame, allocating heap objects (GetComponent, strings, LINQ) insideFixedUpdatetriggers intense GC churn, exacerbating frame drops.


