The game loop is the repeating chain of events that runs your game.
It's still rough and will most likely evolve in future versions to be more reliable / consistent.
Deprecated wiki[]
This wiki is not official
The official wiki was learn.craftstud.io, but that wiki has since been discontinued.
The contents of this page may be outdated, so continue at your own risk.
Execution Order[]
A few things to consider:
- Currently, the game loop walks through the game object tree depth-first and updates each component of each object in the order they were created. It might make more sense to update all components and scripts of the same type together, both for performance (better cache coherence) and consistency reasons.
- Starting with Runtime 0.1.6.0, a Camera's transform is properly computed just before rendering happens so cameras won't lag behind other objects anymore, even if the Camera component is located before a Scripted Behavior component that updates the transform in a game object.
- The Behavior:Update() function is currently called 60 times a second and the game loop will try to catch up by skipping rendering and doing updates several times in a row if the game is laggy. This might change in the future so that Update() is called as often as possible with the elapsed time as an argument and a Tick() or FixedUpdate() function would then be added with the current behavior. This would of course be added with a new API version to avoid breaking existing scripts.