#shorts #unity #gamedev
What is the Update method in Unity, and why should I watch out for it?
The Update method in Unity is called once per frame.
It is easy to calculate that if our game is running at 30 fps then all the instructions in the Update method will be called 30 times per second.
Remember that games often run at 60 fps, sometimes at 120, and sometimes even at 240 frames per second.
Imagine that 240 times per second Unity has to execute a certain sequence of instructions.
Also, don't use some very CPU-costly operations in Update, such as find Object of Type, for example. Because 60 times per second our code will have to search the hierarchy for that one particular object. It is better to do it for example in the Start method and caching it in some variable but definitely not to search for it 240 times per second.
And if you want to know more Subscribe.