Created
January 31, 2024 11:12
-
-
Save unitycoder/be31323048ac654fa6a9158cfde1b1c9 to your computer and use it in GitHub Desktop.
Revisions
-
unitycoder revised this gist
Jan 31, 2024 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,4 +24,7 @@ Most frequently, Update is called several times between each FixedUpdate call. Putting everything in FixedUpdate is incorrect. The game should be able to skip things to adapt to situations of intensive CPU/GPU usage. Otherwise, gameplay will just slow down in those cases. LateUpdate executes in the same cycle as Update, but after all Update functions have been called. ### Source - https://forum.unity.com/threads/update-vs-fixed-update-vs-late-update.307235/#post-5114657 -
unitycoder created this gist
Jan 31, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ Update and FixedUpdate may be seen as two separate execution paths, not necessarily "after" or "before" each other. ### Update - Executes on each visually presented frame. When you see 134 FPS in the stats it means 134 Update cycles per second. - Time.deltaTime is the time between one update cycle to another. - Updated for Unity 2020.2: If VSync is enabled then Update is called at the display's refresh rate and Time.deltaTime is the time between each frame presentation (typically 1 / refresh rate). - Frames may be skipped sometimes if the cpu/gpu load can't keep the display rate. ### FixedUpdate - Executes at a fixed rate (50 Hz by default, defined in Project Settings > Time > Fixed Timestep). - Time.deltaTime is always the value specified in the Fixed Timestep setting. - FixedUpdate cycles won't be skipped ever: instead, the game time may be "slowed down" and/or Update calls will be skipped in order to perform every single FixedUpdate call. There are situations where multiple FixedUpdate calls are performed between each Update call. Most frequently, Update is called several times between each FixedUpdate call. ### Rule of thumb: - Update: visual stuff, camera, effects, things that may be adapted to varying delta time, and skipped for saving CPU/GPU. - FixedUpdate: physics, gameplay, AI, things that depend on precise timing and/or would affect gameplay if skipped. Putting everything in FixedUpdate is incorrect. The game should be able to skip things to adapt to situations of intensive CPU/GPU usage. Otherwise, gameplay will just slow down in those cases. LateUpdate executes in the same cycle as Update, but after all Update functions have been called.