It's all about timing

As with comedy, timing is key to game programming; complex physics calculations are executed while thousands of pixels are rendered on a screen in a matter of milliseconds. Being aware of what is being called at every frame is key to mastering optimization.

In an engine such as Unity, the core game loop and rendering pipeline are abstracted, and we can only hook into its sequencing mechanism by the Scripting API's magic functions, such as: FixedUpdate(), Update(), and LateUpdate(). This approach permits the engine to protect its internal clock and its established sequence of system calls, while giving us the ability to execute code at specific moments of the Game Loop safely.

But the trade-off is that we lose granular ...

Get Hands-On Game Development Patterns with Unity 2019 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.