- Fusion Initialization
- Fusion Update Loop
- Render Loop
The execution loops for Fusion can be broken down into three main loops:
- the Resimulation Loop;
- the Forward Loop; and,
- the Render Loop.
The following sections will present these three loops and the order in which scripts & callbacks are called in them.
INT: Callbacks marked as
INTare used internally by Fusion and are only included for
CB: Callbacks marked as
CBare available to the user and can be hooked into by implementing the associated interface in scripts inheriting from
Download Complete Graphic
The complete execution order graphic can be downloaded HERE.
When Fusion is first started, the
NetworkRunner looks for all components implementing
INetworkRunnerCallbacks on the same object as the Runner. If none can be detected in
Awake() another attempt will be done during the Fusion Update Loop, or -in the rare case the runner is immediately destroyed- during the Shutdown Handling to exit gracefully.
INetworkRunnerCallbacks and not located on the same object or hierarchie level as the
NetworkRunner, need to register themselves at a later point with the
NetworkRunner by calling
NetworkRunner.AddCallbacks() after the Runner has been successfully initialized.
Fusion Update Loop
The core of the Fusion simulation is handled by the Resimulation and Forward loops. Prior to their execution:
- Unity's own FixedUpdate() methods are executed; and,
- The local Physics simulation is run if
After these steps, the Fusion Update Loop starts. The Fusion Update Loop is made of the following execution steps:
- the callbacks registered with the
NetworkObjectspawn queue is processed. This takens place ONLY IF the
SceneManageris busy AND
SceneLoadSpawnMode.Queuedis selected in the
NetworkProjectConfig > Object Settings
- the Resimulation Loop runs.
- the Forward Loop runs.
OnChangedcallbacks are called after both loops have finished executing.
- the Interest Management is updated.
- the Shutdown Handling is triggered if
NetworkRunner.Shutdown()was called in
FixedUpdateNetwork()during the Resimulation or Forward loop.
Update Loop Start
The Resimulation Loop reconciliates the local state with the latest state received from the Server or Host. It does so by resetting the network state to the most recent state received and resimulating all the ticks from the most recent server tick included in the validated state up until the current predicted local tick.
In HostMode & ServerMode
The Forward Loop simulates the next
predicted ticks after the Resimulation Loop finished reconciling the current known
The Forward Loop is the only loop running the simulation; this covers the simulation for objects over which the local simulation has State Authority and the apply the state received for proxy objects.
Update Loop End
The Render Loop is used for all things unrelated to gameplay or the gamestate. Its main purpose is to provide an entry for interpolation and visual feedback logic such as VFX and animation.
Render(), all of Unity's
Update()methods are executed.
Render(), all of Unity's
LateUpdatemethods are executed.
The Shutdown Handling is triggered if
NetworkRunner.Shutdown() was called during the Render Loop.