Update vs FixedUpdate in Unity: Key Differences and When to Use Each
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.
| Aspect | Update | FixedUpdate |
|---|---|---|
| Execution Frequency | Runs once every frame (variable time) | Runs at fixed time intervals (default 0.02s) |
| Use Case | Handle input, animations, and non-physics logic | Handle physics calculations and Rigidbody movement |
| Time Step | Depends on frame rate (Time.deltaTime) | Fixed time step (Time.fixedDeltaTime) |
| Consistency | Can vary with frame rate, less consistent | Consistent timing, ideal for physics |
| Called Before | Called before rendering each frame | Called 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
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); } }
FixedUpdate Equivalent
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)); } }
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
Update for frame-dependent tasks like input and animations.FixedUpdate for physics-related updates to ensure consistent timing.Update frequency varies with frame rate; FixedUpdate runs at fixed intervals.Update can cause unstable behavior.Time.deltaTime in Update and Time.fixedDeltaTime in FixedUpdate.