Hey, I was curious as to what the different kinds of updates do. For example what is a Fixed Update a regular Update and a Late Update just to name the ones that I am using in my game. I tried looking in the API but couldn’t find anything. Could you also let me know when these certain types should and shouldn’t be used. I’m a beginner to all this so I appreciate the help.
Updates (all of them) are called from the engine in order to allow you to advance your scripting in some intervals and at some points in the frame. The when exactly and the intervals are the difference. You can read exact things in the manual (you find the list of callbacks on this page): Unity - Scripting API: MonoBehaviour
Click through all of them, so you will have some info. But in the nutshell:
- update called every frame, right after the engine update
- lateupdate: called every frame, at the end of the update cycle (end of frame)
- fixedupdate: called in different intervals (50Hz default), independently from the frames, its primary purpose to advance the physics system. You can set faster or slower intervals, depends on what the physics you’re developing demands. after every fixedupdate the physics world will be updated (this is why it’s called slower than the normal update)
Oh that makes sense, so basically Fixed Update is used for physics so that the objects can update and move in a more physically correct way. Instead of basing the physics off how fast the computer goes through frames, it is a fixed frame rate no matter what. (You could still change the framerate of it like you said of course)
More or less, yes. Except if the computer under-powered, then this fixed frame-rate will plummet as well.
Why would the fixed frame rate plummet if it is fixed? Shouldn’t it run the same on every computer?
By default it does, but imagine when you give more work to the CPU than it can handle… because of the nature of the processing, the result will that everything will be done, but more slowly. This is the frame drop you can see on games when you have an under-powered computer and too high quality setting.
If the amount of work is less than what needed to have 50 FPS, then everything is dandy, you will get the 50 FPS, but when you add more work, it’s impossible to keep up the 50FPS, you will have either less FPS or entire frames dropped.
IDK if it’s clear enough explanation, LMK if it’s still not clear when you expect less than the set frame-rate.