I think this is so important topic in Unity because all developer is thinking “why am I use FixedUpdate or Update” so I gonna show you these Method.
First, what is a method, methods are code blocks in programming so if you call a new method, actually you call code blocks in the editor.
Method Syntax in Unity
above we are creating a simple method, this method is the start method so it only runs once when the program starts. now, create an Update method.
no longer, we have an Update method, well what is that and why I use, let’s look at that.
Update Method basically is an infinity loop so never ends. if you close the program then it ends. The update method it runs once in each frame. if your fps is low update method runs slower.
no longer, we know the Update method let’s look a FixedUpdate and compare.
FixedUpdate Method like an Update Method but just doesn’t run once in each frame. FixedUpdate is run once in 0.02 seconds. You can change the time. Actually, you don’t care much now So wait a little longer.
FixedUpdate Vs Update
- Update Method for animation and art effects. because higher fps support better quality graphics so no FixedUpdate is used.
- Never writing input in FixedUpdate because input sensitivity will drop and your input will not work.
- Do all physics operations in FixedUpdate because FixedUpdate support Physics Engine
- Use FixedUpdate and Update together.
- FixedUpdate is a constant value, Update speed value may vary.
We learned about FixedUpdate and Update. See you in another post.