The difference between Update, FixedUpdate and LateUpdate

The difference between Update, FixedUpdate and LateUpdate generally create confusion in beginner game developers’ mind. In this post, we will examine what they are, when and why they are used.

Behind the scenes, some pieces of code are executed before the scene is loaded, when started or finished. In addition to this, some pieces of code are executed periodically. We use Update(), FixedUpdate() and LateUpdate() methods to perform this periodic tasks.

Update() Method

Update() is executed every frame. For instance, if the framerate is 60, then the Update method runs 60 times in a second. When we want to control or calculate something which is not related to physics, we use Update(). Since the framerate can be changed due to several reasons, using Update() method in physics calculations may give you unexpected results.

FixedUpdate() Method

FixedUpdate() runs in fixed time steps. Therefore we use this method when a task or a calculation is time-dependent. For example, physics calculations are framerate independent. We have to find the same results even if the framerate changes. Therefore, we write our physics-related code in FixedUpdate() method.

As we mentioned above, this method is executed in fixed time steps. The default time-step is 0.02 seconds. This means that FixedUpdate runs 50 times in a second regardless of the framerate in default options. Nonetheless, this time step can be changed from Edit > Settings > Time > Fixed Timestep. But you should be careful if you already wrote some physics code. You may need to modify the code which you wrote before.

In code, you can access the fixed time step value using Time.fixedDeltaTime.

LateUpdate() Method

LateUpdate() method is also called every frame but after Update() method is executed. Therefore, if you want to check and control something after Update() method finishes its job, then you need to use LateUpdate() method.

Execution Order

As indicated in the Unity Documentation, when a scene is started, physics and physics-related calculations are done first. This means that, FixedUpdate() method is executed before others, since we do physics calculations in this event function.

After FixedUpdate(), Update() method is called. And finally, LateUpdate() is executed.

İsmail Çamönü

Hello, my name is İsmail. I am an indie game developer. I have been developing digital games for five years. I have released several games. I have BS degrees in electrical engineering and physics. I love arts and science. The idea of creating worlds and experiences brought me to the game development which is also directly related to the arts and science.

You may also like...

Leave a Reply

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