Skip to content

Unity script lifecycle

↑

Unity calls certain MonoBehaviour methods at specific points in a frame or a component’s lifetime. The most important choice is which work belongs in which phase. Incorrect placement can cause jitter, missed initialization, or input that feels delayed.

Method Typical responsibility Important detail
Awake Cache references and initialize local state Called as the script instance is loaded, including for inactive scene objects in some circumstances when activated
OnEnable Subscribe to events Can run more than once
Start Setup that depends on other objects being initialized Called before the first Update when enabled
Update Poll frame-based input and gameplay logic Frame-rate dependent
FixedUpdate Apply forces and physics-related changes Fixed timestep; may run zero or multiple times per rendered frame
LateUpdate Follow cameras or logic that should run after Update Runs after normal Update calls
OnDisable Remove event subscriptions Can occur when disabling a script or GameObject
  1. Cache the Rigidbody in Awake, before doing gameplay work.
  2. Read user input in Update so frame events are not skipped.
  3. Apply physics forces or Rigidbody movement in FixedUpdate, using the latest stored input.
  4. Move a non-physics follow camera in LateUpdate after the player has updated.
  5. Unsubscribe from events in OnDisable to avoid duplicated callbacks.
Unity C# | PlayerMovement.cs
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public sealed class PlayerMovement : MonoBehaviour
{
private Rigidbody body;
private Vector2 movement;
private void Awake() => body = GetComponent<Rigidbody>();
private void Update()
{
movement = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
}
private void FixedUpdate()
{
Vector3 force = new(movement.x, 0f, movement.y);
body.AddForce(force * 8f, ForceMode.Acceleration);
}
}

This sample uses Unity’s legacy Input Manager to keep the lifecycle concept short. Projects using the new Input System collect input through the relevant actions instead.

A camera following in Update can appear to trail a moving character if both scripts update in an inconvenient order. Moving the camera to LateUpdate helps, but using physics interpolation may also be necessary when the target moves through FixedUpdate. Diagnose the actual update source rather than moving everything to LateUpdate.

See also: Rigidbody and physics and Collisions and triggers.

INTERACTIVE LIFECYCLE

Select a method to see when and why it is used. This simplified diagram does not imply a fixed one-to-one order between FixedUpdate and Update.

Awake

Set up fields and cache references belonging to this component.

Why it matters

Awake is used for local initialization, not assumptions about the order of other GameObjects.