Skip to content

[Unity] The Difference Between LateUpdate(), FixedUpdate(), Update()

Last Updated on 2021-11-01 by Clay

When I first used Unity to build an Android mobile game, I tried to run the established level on the computer, and gradually fine-tuned the details until I ran very smoothly in the test environment.

However, when I installed it on the test mobile device (OPPO mobile phone) for testing, I found that the overall game was very lagging, and the playing experience was very bad.

After searching many informations, I found it is because I set 60 FPS (Frame Per Second), but the hardware limit of the mobile was only 30 FPS.

And the parameters of my game object such as the game object position are placed in the Update() to detect the keyboard input and change the position. And Update() is a function that is executed once every frame after Awake() and Start() are executed.

If you think about it, you will find that has caused computer environment to execute twice as fast as the mobile phone environment.

No wonder the movement of the game object is very smooth, because the position movement speed of the computer game object is also twice that of the mobile game object.


FixedUpdate()

Unlike Update(), which is executed once per frame, FixedUpdate() is executed at regular time intervals.

What are the benefits of this?

According to the position change of the game object just mentioned, whether it is a computer environment or a mobile phone environment, the game refreshed with different frames can have the same position change speed.

If you want to modify the execution time interval of FixedUpdate(), you can change it from Edit > Settings > Time > Fixed Timestep.

The smaller the number, the faster the FixedUpdate() call speed.


LateUpdate()

Finally, I introduce LateUpdate(). Same as Update(), it will be executed once every frame, the difference is that it will wait for all Update() of scripts to be executed before executing.

So it can be used to update the screen or record the status of all game objects after the update.


Summarize

FunctionsEffects
Update()Execute once per frame.
LateUpdate()Execute once per frame, but will execute after all Update() has been executed
FixedUpdate()Not limited by the number of frames, executed at regular intervals

References


Read More

Tags:

Leave a ReplyCancel reply

Exit mobile version