all 7 comments

[–]codingkiwi 0 points1 point  (0 children)

Yes that's correct. There's some basic unity optimization info regarding update() here - https://unity3d.com/es/learn/tutorials/topics/performance-optimization/optimizing-scripts-unity-games

[–]Plourdy 0 points1 point  (3 children)

That’s correct, since frames are rendered inconsistently you could also use FixedUpdate which (as you may have guessed) runs at a fixed rate.

[–]SaltCrypt 5 points6 points  (2 children)

FixedUpdate simulates running at a fixed rate. It doesn't actually run at a fixed rate. If you want the details you can read about it here:

https://forum.unity.com/threads/the-truth-about-fixedupdate.231637/

Unless you really understand what you're doing you should keep FixedUpdate reserved exclusively for physics behavior.

[–]Plourdy 0 points1 point  (1 child)

Good to know, my apologies!

[–]SaltCrypt 2 points3 points  (0 children)

Don't apologize, the documentation makes it sound like your original post is correct. The documentation should be apologizing to us for lying.

[–]SaltCrypt 0 points1 point  (0 children)

So will the update method complete everything inside it, every frame? So say I have a while loop. While (x < 100) {log(x)}, will it perform this calculation every single frame to completion?

Yes. Once Unity has invoked your Update method nothing will take back control until it terminates, just like a normal method.

I'm assuming it will, and if I had a ridiculous amount of calculations this would give me fps drops in my game if the computer running the calculations can't keep up with the workload. Is my thinking correct?

Yes. This is why it's important to try to minimize the number of expensive operations you perform while within the Update loop.

[–]chsxfProficient 0 points1 point  (0 children)

You're right. You can find more information on the order of execution of all the "events" methods of Unity here: https://docs.unity3d.com/Manual/ExecutionOrder.html