Unity: FixedUpdate, Update and LateUpdate

In this blog I will explain the differences among FixedUpdate, Update and LateUpdate. Each one has a correct way to use it. And I hope that reading this blog help you to understand a little more about this topic

1.FixedUpdate

FixedUpdate has the frequency of the system physics, so is in this method that the physics calculations are made. It is recommended to use this when it comes to Rigidbodys, some triggers and collisions.

It is independent of the frame rate, this is useful because in the case of Update you will find that there, may be, some lengthening or shortening in the frame rate depending on the amount of actions that must be executed at a given time.

For default FixedUpdate is call every 0.02 seconds.

In the image above you will find the way to modify the default time of FixedUpdate (the recommendation is not to change it)

2. Update

The Update method is called for each frame so it depends on the time between frames (frame rate), and in turn that depends on the amount of actions that have to be executed in a given time. Taking this into account, we could find that in one second you have 57 frames and in another 59 frames.

To solve this problem you can multiple this by Time. DeltaTime with the objective to obtain a more reliable frame per second rate.

In the above explanation, the inconsistency among some duration of frames can cause that if you call a physic calculations here you could have unexpected results

There are many things you can call in Update like input controls and simple timers.

3. LateUpdate

How it tells us its name, it is the last to be called of the three, the usefulness of this method is for example when we want something to be called after the other two, the easiest example is a camera.

Imagine you have and object follow by the camera, you need that the camera move after all the physics and other calculations are done, is for this that you use the LateUpdate.

If you find this blog useful let us a comment, and follow us in our Instagram @tortugamedev and Twitter @Totuas2.

And don’t forget to check out the rest of the blogs!!

Bibliography and further reading

https://docs.unity3d.com/ScriptReference/MonoBehaviour.FixedUpdate.html

https://docs.unity3d.com/ScriptReference/MonoBehaviour.Update.html

https://docs.unity3d.com/ScriptReference/MonoBehaviour.LateUpdate.html

Leave a Comment

Your email address will not be published.