The MonoBehaviour lifecycle helps you control when your game code runs. It organizes your code to run at the right time during the game.
MonoBehaviour lifecycle in Unity
void Awake() { }
void Start() { }
void Update() { }
void FixedUpdate() { }
void LateUpdate() { }
void OnEnable() { }
void OnDisable() { }
void OnDestroy() { }These are special methods in a MonoBehaviour script that Unity calls automatically.
You do not call these methods yourself; Unity manages when they run.
void Awake() {
Debug.Log("Awake called");
}void Start() {
Debug.Log("Start called");
}void Update() {
Debug.Log("Update called every frame");
}void FixedUpdate() {
Debug.Log("FixedUpdate called on fixed time steps");
}This script shows the main MonoBehaviour lifecycle methods. Unity calls them automatically in this order: Awake, Start, then Update every frame, FixedUpdate on fixed intervals, and OnDestroy when the object is removed.
using UnityEngine; public class LifecycleExample : MonoBehaviour { void Awake() { Debug.Log("Awake: Initialize variables"); } void Start() { Debug.Log("Start: Setup before first frame"); } void Update() { Debug.Log("Update: Runs every frame"); } void FixedUpdate() { Debug.Log("FixedUpdate: Runs on fixed time steps"); } void OnDestroy() { Debug.Log("OnDestroy: Cleanup before object is destroyed"); } }
Awake is called even if the script is disabled, but Start only runs if the script is enabled.
Update runs every frame, so keep code here efficient to avoid slowing the game.
FixedUpdate is best for physics-related code because it runs at consistent time steps.
MonoBehaviour lifecycle methods let you run code at specific times during the game.
Awake and Start run once at the beginning; Update and FixedUpdate run repeatedly.
Use OnDestroy to clean up before the object is removed.