Course contentsShow
← Unity Game Development
Lesson 210 of 8283. Physics and InteractionFree lesson

Configuring Fixed Timestep for Simulation Stability

Learners will adjust the Fixed Timestep settings to balance simulation accuracy against performance costs in complex physics scenes.

In this lesson, you will learn how to fine-tune the Fixed Timestep setting to ensure your physics simulations remain stable and predictable even when handling complex mechanical systems.

Understanding the Physics Heartbeat

In Unity, the physics engine doesn't update every single frame like your rendering does. Instead, it runs on a dedicated timer called the Fixed Timestep. By default, this is set to 0.02 seconds (50 updates per second). This interval is the "heartbeat" of your simulation. If your scene features complex joints, fast-moving objects, or intricate pulley systems, this default heartbeat might be too slow, causing objects to jitter or joints to "explode" under tension.

Balancing Stability and Performance

To adjust this, go to Edit > Project Settings > Time. The Fixed Timestep field dictates how often FixedUpdate is called.

  • Decreasing the value (e.g., 0.01): This makes the physics engine tick more frequently. You gain higher simulation accuracy, which is excellent for complex joints or high-speed collisions. However, it increases the CPU load because the engine has to perform calculations more often per second.
  • Increasing the value (e.g., 0.04): This reduces the CPU load, which can help performance on low-end devices. The downside is that physics will appear less precise, and complex interactions—like those mechanical levers or destructible walls we’ve built—may become unstable or fall through colliders.

When to Adjust

If you notice your mechanical doors or spring-based grabbing mechanisms struggling to maintain their position, try lowering the Fixed Timestep slightly. It is essentially a trade-off: higher values favor performance, while lower values favor rigid, stable simulation.

// Remember: Physics calculations happen inside FixedUpdate.
// If you change the Fixed Timestep in Project Settings,
// your FixedUpdate logic will simply run at that new frequency.
void FixedUpdate() 
{
    // Apply forces here to ensure stability
    rb.AddForce(Vector3.up * jumpStrength, ForceMode.VelocityChange);
}

Keep in mind that if you change this value, you should test your physics-based traps and puzzles thoroughly to ensure the behavior remains consistent across different frame rates.

Key Takeaway: The Fixed Timestep acts as your simulation’s resolution; lowering it improves physics stability for complex mechanisms at the cost of higher CPU usage.