This document is about: FUSION 1
SWITCH TO

This page is a work in progress and could be pending updates.

Execution Order

Overview

The execution loops for Fusion can be broken down into three main loops:

  1. the Resimulation Loop;
  2. the Forward Loop; and,
  3. 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 INT are used internally by Fusion and are only included for
  • CB: Callbacks marked as CB are available to the user and can be hooked into by implementing the associated interface in scripts inheriting from NetworkBehaviour and SimulationBehaviour.

Download Complete Graphic

The complete execution order graphic can be downloaded HERE.

Fusion Initialization

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.

Scripts implementing 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.

networkrunner initialization
NetworkRunner Initialization

Fusion Update Loop

The core of the Fusion simulation is handled by the Resimulation and Forward loops. Prior to their execution:

  1. Unity's own FixedUpdate() methods are executed; and,
  2. The local Physics simulation is run if PhysicsMode.None was selected.
before fusion update loop
Before the Fusion Update Loop

After these steps, the Fusion Update Loop starts. The Fusion Update Loop is made of the following execution steps:

  1. the callbacks registered with the NetworkRunner are executed.
  2. the NetworkObject spawn queue is processed. This takens place ONLY IF the SceneManager is busy AND SceneLoadSpawnMode.Queued is selected in the NetworkProjectConfig > Object Settings
  3. the Resimulation Loop runs.
  4. the Forward Loop runs.
  5. OnChanged callbacks are called after both loops have finished executing.
  6. the Interest Management is updated.
  7. the Shutdown Handling is triggered if NetworkRunner.Shutdown() was called in FixedUpdateNetwork() during the Resimulation or Forward loop.
networkprojectconfig
Scene Load Spawn Mode setting

Update Loop Start

fusion update loop start
Fusion Update Loop Start

Resimulation Loop

The Resimulation Loop only runs in ServerMode and HostMode

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.

fusion resimulation
The Fusion Resimulation Loop

Forward Loop

The Forward Loop runs in all modes - including SharedMode

In HostMode & ServerMode

The Forward Loop simulates the next predicted ticks after the Resimulation Loop finished reconciling the current known [Networked] state.

In SharedMode

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.

fusion forward
The Fusion Forward Loop

Update Loop End

fusion update loop end
Fusion Update Loop End

Render Loop

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.

  • Before Render(), all of Unity's Update() methods are executed.
  • After Render(), all of Unity's LateUpdate methods are executed.

The Shutdown Handling is triggered if NetworkRunner.Shutdown() was called during the Render Loop.

fusion render
The Fusion Render Loop
Back to top