Overview
In Unity scripting, Update() is one of the most frequently used functions, but there's also a very similar function called FixedUpdate(). Both execute repeated processing, but their execution timing and primary uses are fundamentally different.
Confusing these two causes various problems: choppy character movement, unstable physics, and more. This article clarifies the roles of Update() and FixedUpdate() and explains when to use each.
Execution Timing Differences
The most important difference between Update() and FixedUpdate() is when they're called.
Update()
- Called once per frame.
- Execution interval depends on frame rate. On a high-performance PC running at 120fps, it's called 120 times per second; on a low-performance system at 30fps, only 30 times per second. The interval is not constant.
FixedUpdate()
- Called at fixed time intervals.
- Default interval is 0.02 seconds, configurable in
Edit > Project Settings > TimeunderFixed Timestep. - Execution interval is independent of frame rate. Guaranteed to be called at constant intervals.
At high frame rates, Update() may be called several times before one FixedUpdate() call. At low frame rates, FixedUpdate() may be called multiple times within a single frame.
Use Case Guidelines
This timing difference clearly separates their uses.
Primary Uses for Update()
Suitable for processing that may change state each frame without strict time constraints. Update synchronizes with frame rendering, making it ideal for visual processing and input detection.
- Input handling: Check player input every frame with
Input.GetKey(),Input.GetMouseButtonDown(), etc. - Character movement (without physics): Simple movement using
transform.Translate(). - Timers and cooldowns
- UI updates
When performing movement in Update, always multiply by Time.deltaTime. Time.deltaTime represents the time elapsed since the previous frame. Multiplying movement by this keeps speed consistent regardless of frame rate fluctuation.
using UnityEngine;
public class SimplePlayerMovement : MonoBehaviour
{
public float speed = 5f;
void Update()
{
// Get input
float horizontal = Input.GetAxis("Horizontal"); // -1.0f to 1.0f
// Multiply by Time.deltaTime for frame-rate-independent movement
transform.Translate(Vector3.right * horizontal * speed * Time.deltaTime);
}
}
Primary Uses for FixedUpdate()
Because execution interval is guaranteed, all physics-related processing should be in FixedUpdate(). Unity's physics engine (PhysX) updates in sync with FixedUpdate() timing.
- Applying force to
Rigidbody: Add force withrb.AddForce()or torque withrb.AddTorque(). - Changing
Rigidbodyvelocity: Directly modifyrb.velocity. - Physics-based character controllers
If you continuously apply force to Rigidbody in Update(), frame rate fluctuation changes how many times force is applied, resulting in unstable object movement. Using FixedUpdate() ensures force is applied at constant intervals for reproducible, stable physics behavior.
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class PhysicsPlayerMovement : MonoBehaviour
{
public float moveForce = 50f;
private Rigidbody rb;
void Awake()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate()
{
// Get input
float horizontal = Input.GetAxis("Horizontal");
// Apply force to move via Rigidbody
rb.AddForce(Vector3.right * horizontal * moveForce);
}
}
Summary
Proper use of Update() vs FixedUpdate() is crucial for Unity performance and behavior stability. Keep these rules in mind:
Update() | FixedUpdate() | |
|---|---|---|
| Timing | Per frame (variable) | Fixed interval (constant) |
| Primary Use | Input, non-physics movement, game logic | Physics with Rigidbody |
| Note | Use Time.deltaTime | Time.deltaTime not needed (auto-handled) |
"Physics in FixedUpdate, everything else in Update"
Remember this simple principle to prevent many problems. Understand each function's role and develop the habit of writing code in the appropriate place.