Site icon Teaching Newbies since 2014

Unity3D Scripting API #6: LateUpdate()☑️

Unity3D Scripting API

Unity3D Scripting API

Unity3D Scripting API #6: LateUpdate()☑️

LateUpdate():

☑️ This is called after each Update() method call

☑️This is useful to ensure all Update() related calculations are completed, and then any other dependent calculations can be called. For example, if you need to integrate a third-person camera to follow a character, then it should be implemented inside LateUpdate() method. This ensures that the camera will track the character after its movement has been updated.

All objects on the scene will be moved first and then the camera will be moved last.

Order of execution:

☑️FixedUpdate(): Called after a fixed time of 0.02 seconds

☑️Update(): Called once after every frame. Depends on the frame rate

☑️LateUpdate(): Called after the Update() method

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CubeController : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Hello");
    }

    // Update is called once per frame

    void Update()
    {
        Debug.Log("-------------Update Method");
    }

    void FixedUpdate()
    {
        Debug.Log("Fixed Method:");
    }
    void LateUpdate()
    {
        Debug.Log("--------Late Method:----------");
    }
}
Exit mobile version