0
0
UnityComparisonBeginner · 4 min read

Update vs FixedUpdate in Unity: Key Differences and When to Use Each

In Unity, Update runs once per frame and is best for handling input and non-physics logic, while FixedUpdate runs at fixed time intervals and is designed for physics calculations to ensure consistent behavior regardless of frame rate.
⚖️

Quick Comparison

This table summarizes the main differences between Update and FixedUpdate in Unity.

AspectUpdateFixedUpdate
Execution FrequencyRuns once every frame (variable time)Runs at fixed time intervals (default 0.02s)
Use CaseHandle input, animations, and non-physics logicHandle physics calculations and Rigidbody movement
Time StepDepends on frame rate (Time.deltaTime)Fixed time step (Time.fixedDeltaTime)
ConsistencyCan vary with frame rate, less consistentConsistent timing, ideal for physics
Called BeforeCalled before rendering each frameCalled before physics simulation step
⚖️

Key Differences

Update is called once per frame and its frequency depends on the frame rate, which can vary depending on the device's performance. This makes it ideal for tasks like reading player input, updating UI, or playing animations where timing can be flexible.

In contrast, FixedUpdate runs at a consistent, fixed interval independent of frame rate. This fixed timing is crucial for physics calculations to ensure stable and predictable simulation results, such as moving objects with Rigidbody components.

Using Time.deltaTime inside Update helps smooth out frame rate differences, while Time.fixedDeltaTime inside FixedUpdate ensures physics updates happen evenly. Mixing these methods incorrectly can cause jittery movement or inconsistent physics behavior.

💻

Update Code Example

csharp
using UnityEngine;

public class MoveWithUpdate : MonoBehaviour
{
    public float speed = 5f;

    void Update()
    {
        float move = Input.GetAxis("Horizontal") * speed * Time.deltaTime;
        transform.Translate(move, 0, 0);
    }
}
Output
The object moves smoothly left or right based on player input, updated every frame.
↔️

FixedUpdate Equivalent

csharp
using UnityEngine;

public class MoveWithFixedUpdate : MonoBehaviour
{
    public float speed = 5f;
    private Rigidbody rb;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    void FixedUpdate()
    {
        float move = Input.GetAxis("Horizontal") * speed * Time.fixedDeltaTime;
        rb.MovePosition(rb.position + new Vector3(move, 0, 0));
    }
}
Output
The Rigidbody moves smoothly left or right with physics updates at fixed intervals.
🎯

When to Use Which

Choose Update when you need to handle player input, update UI elements, or animate objects without physics. It runs every frame and adapts to frame rate changes.

Choose FixedUpdate when working with physics, such as moving objects with Rigidbody, applying forces, or detecting collisions. Its fixed timing ensures stable physics simulation.

Using the right method prevents jitter and keeps gameplay smooth and consistent.

Key Takeaways

Use Update for frame-dependent tasks like input and animations.
Use FixedUpdate for physics-related updates to ensure consistent timing.
Update frequency varies with frame rate; FixedUpdate runs at fixed intervals.
Mixing physics code in Update can cause unstable behavior.
Always multiply movement by Time.deltaTime in Update and Time.fixedDeltaTime in FixedUpdate.