Network Runner
Overview
The NetworkRunner
is Fusion’s central Unity component which represents a single networked Peer. All messaging, matchmaking, connecting, spawning, simulation and state replication are orchestrated by this component.
Usage
Creation
The Network Runner GameObject can be created in three ways:
- Instantiated from a prefab at runtime
- As a GameObject in the Unity scene
- Dynamically created via code by adding a
NetworkRunner
component to a GameObject
Startup and Connecting
Once created, a NetworkRunner
instance can connect to matchmaking, or it can create/join a Room.
Read the Matchmaking Basics docs to learn about sessions and matchmaking.
Creating or Joining a Room
Calling StartGame()
from a NetworkRunner
instance creates a Peer, which joins or creates a room as specified by the StartGameArgs
argument. However, in Single Mode no connection to the Photon servers is made and no Room is created.
Starting a runner by default will not load any scene as networked. A NetworkSceneInfo
can be passed into the StartGameArgs
to define which scene the runner should load.
- The current active scene can be passed in to start the runner in the current scene and spawn all the NetworkObjects in it.
- Another scene can be passed to have the runner load that scene and spawn all the NetworkObjects in it. This option is useful when starting the runner from a "menu" scene to transition to a "gameplay" scene.
Example of starting a NetworkRunner
in the currently active scene (requires the scene to be added to the build settings):
C#
var sceneRef = SceneRef.FromIndex(SceneManager.GetActiveScene().buildIndex);
NetworkSceneInfo info = new NetworkSceneInfo();
info.AddSceneRef(sceneRef, LoadSceneMode.Single);
runner.StartGame(new StartGameArgs()
{
Scene = info,
GameMode = GameMode.Shared,
});
For more information about scene loading and how to switch scenes while the runner is running see Scene Loading
IMPORTANT: You can only use a NetworkRunner
once. Once that NetworkRunner disconnects from a game session or fails to connect it should be destroyed, and a new Network Runner instance should be created to start any new game sessions.
Runner Support Components
On startup, the NetworkRunner
component will find and register all child SimulationBehaviour
components. These components will receive FixedUpdateNetwork()
and Render()
callbacks.
The NetworkRunner
also finds all child components which implement the INetworkRunnerCallbacks
interface and registers them for callbacks.
Built-In Fusion Runner Components
There are a number of Fusion components that can be added to the Network Runner game object which extend the Runner's functionality.
RunnerAOIGizmos
- Add this component to enable Area Of Interest gizmos.
Custom SimulationBehaviours Runner Components
You can make your own Runner-specific support components by adding a component which inherits from SimulationBehaviour
or implements INetworkRunnerCallbacks
(or both) to your Network Runner game object.
These components will automatically be found by the NetworkRunner
instance when NetworkRunner.StartGame()
is called, and the associated callbacks will be called when applicable.
Custom INetworkRunnerCallbacks
On startup, the NetworkRunner
component will find and register all child components with INetworkRunnerCallbacks
. See INetworkRunnerCallbacks API Reference.
NOTE: Some callbacks may not be applicable and will not be called, due to execution order. For example, OnPlayerJoined()
will not fire for previously joined players.

Network Connection
Connections and transport handling for the peer is wrapped by the NetworkRunner
. It handles connections to the Matchmaking Servers, Room Servers and Game Server.
Tick Management
The NetworkRunner is responsible for determining when ticks need to be simulated and re-simulated. Every Unity Update, the NetworkRunner
determines how many ticks need to be simulated, based on the amount of time that has passed since the previous tick simulation.
When a tick is simulated, Fusion calls all FixedUpdateNetwork()
callbacks.