Difference between Update, FixedUpdate and LateUpdate: Unity Tutorial

This article explains difference between Update, FixedUpdate and LateUpdate monobehaviour functions in the unity application.

Update

Update is called once per frame from every script in which it is defined. Calling of Update function is dependent on the frame rate; for high frame rate the time interval will be low but for the low frame rate the time interval will be high.

The time interval to call update is not fixed; it depends on how much time required to complete the individual frame. If a frame takes longer/shorter time to process as compared to the other one then the update time interval becomes different for frames.

In unity, Time.deltaTime will provide you time in seconds to complete the last frame. This can be used to make your game frame independent.

Update, FixedUpdate and LateUpdate

Update is commonly used for:

  • Moving Game Objects (Non-Physics): While moving a GameObject, multiply your movement values by Time.deltaTime to make it frame rate independent.
  • Receiving user inputs like mouse down or key press.
  • Implementing Simple timers

FixedUpdate

FixedUpdate is independent from the frame rate. The time interval is to call FixedUpdate is constant; as it is called on a reliable timer.

FixedUpdate can be called multiple times per frame if frame rate is low or it may not be called per frame if the frame rate will be high. So, it is quite possible that FixedUpdate will be called more than Update.

When Time.deltaTime will be called from FixedUpdate, it will return the constant time interval.There is no need to multiply your values to Time.deltaTime inside the FixedUpdate.

Update, FixedUpdate and LateUpdate

All the physics related calculations and updates are called immediately after FixedUpdate. So, its good to handle all physics related calculation inside FixedUpdate.

LateUpdate

LateUpdate is also called per frame. It is called after all other Update functions. Time.deltaTime will provide the time interval for the LateUpdate.

Update, FixedUpdate and LateUpdate

This is useful to ensure all other Update related calculation is complete and other dependent calculation can be called. For example, if you need to integrate a third-person camera to follow any object; then it should be implemented inside the LateUpdate. It is make sure that camera will track the object after its movement and rotation update.

Hope you get an idea about difference between Update, FixedUpdate and LateUpdate in unity application. Post your comments for query and feedback. Thanks for reading.

Share Button
The following two tabs change content below.
Gyanendu Shekhar is a technology enthusiast. He loves to learn new technologies. His area of interest includes Microsoft technologies, Augmented reality, Virtual reality, unity3d and android development.

Gyanendu Shekhar

Gyanendu Shekhar is a technology enthusiast. He loves to learn new technologies. His area of interest includes Microsoft technologies, Augmented reality, Virtual reality, unity3d and android development.

Leave a Reply

Your email address will not be published. Required fields are marked *