Photon Fusion 1.1.2

Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | List of all members
NetworkRunner Class Reference

Represents a Server or Client Simulation. More...

Inherits Behaviour, ILogBuilder, ILogBuilder, and Simulation.ICallbacks.

Public Types

enum class  BuildTypes
 Enumeration of Fusion.Runtime.dll options. More...
 
enum class  States
 Initialization stages of Fusion More...
 

Public Member Functions

delegate void OnBeforeSpawned (NetworkRunner runner, NetworkObject obj)
 Delegate type for on before spawned callback More...
 
void Disconnect (PlayerRef player)
 Disconnect a player from the server More...
 
Task Shutdown (bool destroyGameObject=true, ShutdownReason shutdownReason=ShutdownReason.Ok, bool forceShutdownProcedure=false)
 Initiates a Simulation.Dispose. More...
 
void SinglePlayerPause ()
 Pauses the game in single player More...
 
void SinglePlayerContinue ()
 Continues a paused game in single player More...
 
void SinglePlayerPause (bool paused)
 Sets the paused state in a single player More...
 
void SetInterestGroup (NetworkObject obj, PlayerRef player, string group, bool interested)
 Add or remove Player's interest in a specific named Interest Group for a specific NetworkObject.
SimulationConfig.ReplicationMode must be set to SimulationConfig.StateReplicationModes.EventualConsistency. More...
 
int GetInterfaceListsCount (Type type)
 
SimulationBehaviour GetInterfaceListHead (Type type, int index)
 
SimulationBehaviourListScope GetInterfaceListHead (Type type, int index, out SimulationBehaviour head)
 
SimulationBehaviour GetInterfaceListPrev (SimulationBehaviour behaviour)
 
SimulationBehaviour GetInterfaceListNext (SimulationBehaviour behaviour)
 
int? GetPlayerActorId (PlayerRef player)
 Gets Player's Actor Number (ID). Only usable in shared mode.
More...
 
string GetPlayerUserId (PlayerRef player)
 Gets Player's UserID. Only usable in shared mode. More...
 
void SetPlayerObject (PlayerRef player, NetworkObject networkObject)
 Sets the network object associated with this player More...
 
NetworkObject GetPlayerObject (PlayerRef player)
 Gets the network object associated with a specific player More...
 
bool TryGetPlayerObject (PlayerRef player, out NetworkObject networkObject)
 
List< T > GetAllBehaviours< T > ()
 
void GetAllBehaviours< T > (List< T > result)
 
double GetPlayerRtt (PlayerRef playerRef)
 Returns the player round trip time (ping) in seconds More...
 
void SendRpc (SimulationMessage *message)
 Sends RPC message. Not meant to be used directly, ILWeaver calls this. More...
 
void SendRpc (SimulationMessage *message, out RpcSendResult info)
 Sends RPC message. Not meant to be used directly, ILWeaver calls this. More...
 
bool IsPlayerValid (PlayerRef player)
 
bool IsPlayerActive (PlayerRef player)
 
byte[] GetPlayerConnectionToken (PlayerRef player)
 Returns a copy of the Connection Token used by a Player when connecting to this Server. Only available on Server. It will return null if running on a Client or the Connection token is missing More...
 
ConnectionType GetPlayerConnectionType (PlayerRef player)
 Return the ConnectionType with a Remote PlayerRef. Valid only when invoked from a Server (NetworkRunner.IsServer) More...
 
SimulationBehaviour[] GetAllBehaviours (Type type)
 Returns array of all SimulationBehaviour registered with this NetworkRunner. More...
 
void AddCallbacks (params INetworkRunnerCallbacks[] callbacks)
 Register an INetworkRunnerCallbacks instance for callbacks from this NetworkRunner. More...
 
void RemoveCallbacks (params INetworkRunnerCallbacks[] callbacks)
 Unregister an INetworkRunnerCallbacks instance for callbacks from this NetworkRunner. More...
 
void SendReliableDataToPlayer (PlayerRef player, byte[] data)
 Send an arbitrary data buffer to a target Player More...
 
void SendReliableDataToServer (byte[] data)
 Send an arbitrary data buffer to the Server More...
 
void SetPlayerAlwaysInterested (PlayerRef player, NetworkObject networkObject, bool alwaysInterested)
 Flags this player as always interested in this object. Means it does not have to be in a players area of interest to be replicated. More...
 
void AddPlayerAreaOfInterest (PlayerRef player, Vector3 position, float extent, int layersMask=-1)
 Adds an area of interest region for a specific player. A player can have multiple areas of interest regions added. These are cleared every tick, so this needs to be called every NetworkBehaviour.FixedUpdateNetwork(). More...
 
T? GetInputForPlayer< T > (PlayerRef player)
 Returns the NetworkInput data from player, converted to the indicated INetworkInput. More...
 
NetworkInputGetRawInputForPlayer (PlayerRef player)
 Returns the unconverted unsafe NetworkInput for the indicated player. More...
 
bool TryGetInputForPlayer< T > (PlayerRef player, out T input)
 Outputs the NetworkInput from player, translated to the indicated INetworkInput. More...
 
NetworkObject FindObject (NetworkId oref)
 Get the NetworkObject instance for this NetworkRunner from a NetworkId. More...
 
bool TryFindObject (NetworkId oref, out NetworkObject obj)
 Get the NetworkObject instance for this NetworkRunner from a NetworkId. More...
 
bool TryFindBehaviour (NetworkBehaviourId bref, out NetworkBehaviour behaviour)
 Get the NetworkBehaviour instance for this NetworkRunner from a NetworkBehaviourId. More...
 
bool TryFindBehaviour< T > (NetworkBehaviourId id, out T behaviour)
 
bool GetInterpolationData (NetworkBehaviour behaviour, bool predicted, out InterpolationData data)
 Gets the InterpolationData for the current SimulationStages stage. For use in the NetworkBehaviour.Render() callback. More...
 
TryGetNetworkedBehaviourFromNetworkedObjectRef< T > (NetworkId id)
 Tries to return the first instance of T found on the root of a NetworkObject. More...
 
NetworkId TryGetObjectRefFromNetworkedBehaviour (NetworkBehaviour behaviour)
 
NetworkBehaviourId TryGetNetworkedBehaviourId (NetworkBehaviour behaviour)
 
bool Exists (NetworkObject obj)
 Returns if the Fusion.Simulation contains a reference to a NetworkObject in the current State SimulationSnapshot. More...
 
bool Exists (NetworkId id)
 Returns if the Fusion.Simulation contains a NetworkObject with given id in the current State SimulationSnapshot. More...
 
Spawn< T > (T prefab, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkObjectPredictionKey? predictionKey=null, bool syncPhysics=true)
 Attempts to network instantiate a NetworkObject using a Component type that is part of a NetworkObject More...
 
NetworkObject Spawn (GameObject prefab, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkObjectPredictionKey? predictionKey=null, bool syncPhysics=true)
 Attempts to network instantiate a NetworkObject using a GameObject. The supplied GameObject must have a NetworkObject component. More...
 
NetworkObject Spawn (NetworkObject prefab, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkObjectPredictionKey? predictionKey=null, bool syncPhysics=true)
 Attempts to network instantiate a NetworkObject using a NetworkObject prefab. Note: position and rotation values are only used locally for the instantiation of the object, and are not inherently networked. Use NetworkPositionRotation, or any of its derived classes such as NetworkTransform to replicate the initial transform state. More...
 
NetworkObject Spawn (NetworkPrefabRef prefabRef, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkObjectPredictionKey? predictionKey=null)
 Attempts to network instantiate a NetworkObject using a NetworkPrefabRef. Note: position and rotation values are only used locally for the instantiation of the object, and are not inherently networked. Use NetworkPositionRotation, or any of its derived classes such as NetworkTransform to replicate the initial transform state. More...
 
NetworkObject Spawn (NetworkPrefabAsset prefabAsset, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkObjectPredictionKey? predictionKey=null)
 Attempts to network instantiate a NetworkObject using a NetworkPrefabAsset Note: position and rotation values are only used locally for the instantiation of the object, and are not inherently networked. Use NetworkPositionRotation, or any of its derived classes such as NetworkTransform to replicate the initial transform state. More...
 
NetworkObject Spawn (NetworkObjectGuid prefabGuid, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkObjectPredictionKey? predictionKey=null, bool syncPhysics=true)
 Attempts to network instantiate a NetworkObject using a NetworkObjectGuid Note: position and rotation values are only used locally for the instantiation of the object, and are not inherently networked. Use NetworkPositionRotation, or any of its derived classes such as NetworkTransform to replicate the initial transform state. More...
 
NetworkObject Spawn (NetworkPrefabId prefabId, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkObjectPredictionKey? predictionKey=null, bool syncPhysics=true)
 Attempts to network instantiate a NetworkObject using a NetworkPrefabId Note: position and rotation values are only used locally for the instantiation of the object, and are not inherently networked. Use NetworkPositionRotation, or any of its derived classes such as NetworkTransform to replicate the initial transform state. More...
 
void Despawn (NetworkObject networkObject, bool allowPredicted=false)
 Destroys a NetworkObject. More...
 
GetGlobal< T > ()
 
AddOrGetGlobal< T > ()
 Ensures that a specific SimulationBehaviour component exists on this NetworkRunner gameobject. More...
 
void AddGlobal< T > ()
 
void RemoveGlobal< T > ()
 Removes a specific SimulationBehaviour from this NetworkRunner gameobject, if it exists. More...
 
void AddSimulationBehaviour (SimulationBehaviour behaviour, NetworkObject obj=null)
 Register a SimulationBehaviour instance with the SimulationBehaviourUpdater. Invalid if NetworkRunner has not been started and initialized. More...
 
void RemoveSimulationBehavior (SimulationBehaviour behaviour)
 Unregister a SimulationBehaviour instance from the SimulationBehaviourUpdater callbacks. Invalid if NetworkRunner has not been started and initialized. More...
 
void Attach (NetworkObject networkObject, PlayerRef? inputAuthority=null)
 Attaches a user created network object to the network More...
 
void RegisterUniqueObjects (IEnumerable< NetworkObject > objects)
 
void RegisterSceneObjects (IEnumerable< NetworkObject > objects)
 
RpcTargetStatus GetRpcTargetStatus (PlayerRef target)
 
bool HasAnyActiveConnections ()
 
int GetHashCodeForLogger ()
 
IEnumerable< NetworkObjectGetResumeSnapshotNetworkObjects ()
 Iterate over the old NetworkObjects from the Resume Snapshot More...
 
IEnumerable<(NetworkObject, NetworkObjectHeaderPtr)> GetResumeSnapshotNetworkSceneObjects ()
 Iterate over the Scene NetworkObjects from the Resume Snapshot while giving the reference of the old Snapshot data associated with that particular Scene Object More...
 
async Task< StartGameResultJoinSessionLobby (SessionLobby sessionLobby, string lobbyID=null, AuthenticationValues authentication=null, AppSettings customAppSettings=null)
 Join the Peer to a specific Lobby, either a prebuild or a custom one More...
 
Task< StartGameResultStartGame (StartGameArgs args)
 Starts the local Fusion Runner and takes care of all major setup necessary More...
 
void SetActiveScene (SceneRef scene)
 Update the current Active Scene More...
 
void InvokeSceneLoadStart ()
 Invoke INetworkRunnerCallbacks.OnSceneLoadStart(NetworkRunner) on all implementations More...
 
void InvokeSceneLoadDone ()
 Invoke INetworkRunnerCallbacks.OnSceneLoadDone(NetworkRunner) on all implementations More...
 
bool TryMultiplePeerAssignTempScene ()
 Try to create a temp empty scene for PhysicsScene More...
 
PhysicsScene GetPhysicsScene ()
 Get the 3D Physics scene being used by this Runner. More...
 
PhysicsScene2D GetPhysicsScene2D ()
 Get the 2D Physics scene being used by this Runner. More...
 
GameObject InstantiateInRunnerScene (GameObject original, Vector3 position, Quaternion rotation)
 Instantiates an object in the scene of this runner More...
 
GameObject InstantiateInRunnerScene (GameObject original)
 Instantiates an object in the scene of this runner More...
 
InstantiateInRunnerScene< T > (T original)
 Instantiates an object in the scene of this runner More...
 
InstantiateInRunnerScene< T > (T original, Vector3 position, Quaternion rotation)
 Instantiates an object in the scene of this runner More...
 
void MoveToRunnerScene< T > (T component)
 Moves an object to the scene of this runner More...
 
void MoveToRunnerScene (GameObject go)
 Moves an object to the scene of this runner More...
 
bool EnsureRunnerSceneIsActive (out Scene previousActiveScene)
 If running in NetworkProjectConfig.PeerModes.Multiple peer mode and the current active scene is different than MultiplePeerUnityScene, switches active scene to MultiplePeerUnityScene, stores the previous active scene in previousActiveScene and returns true. Returns false otherwise. More...
 
- Public Member Functions inherited from Behaviour
AddBehaviour< T > ()
 Wrapper for Unity's GameObject.AddComponent() More...
 
bool TryGetBehaviour< T > (out T behaviour)
 Wrapper for Unity's GameObject.TryGetComponent() More...
 
GetBehaviour< T > ()
 Wrapper for Unity's GameObject.GetComponentInChildren() More...
 

Static Public Member Functions

static List< NetworkRunner >.Enumerator GetInstancesEnumerator ()
 Get enumerator for the collection of all NetworkRunners. Allows to enumerate alloc-free. More...
 
static NetworkRunner GetRunnerForGameObject (GameObject gameObject)
 Get the NetworkRunner a GameObject instance belongs to. More...
 
static NetworkRunner GetRunnerForScene (Scene scene)
 Get the NetworkRunner from a specific Scene More...
 
- Static Public Member Functions inherited from Behaviour
static void DestroyBehaviour (Behaviour behaviour)
 Wrapper for Unity's GameObject.Destroy() More...
 

Static Public Attributes

static Simulation.IDeltaCompressor BurstDeltaCompressor
 

Properties

static BuildTypes BuildType [get]
 Get Fusion.Runtime.dll build type. More...
 
bool IsVisible [get, set]
 Change the visibility of this NetworkRunner when running in Multiple Peer Mode More...
 
bool ProvideInput [get, set]
 Indicates if this NetworkRunner is collecting PlayerRef INetworkInput. More...
 
SimulationConfig.Topologies Topology [get]
 The current topology used More...
 
Simulation Simulation [get]
 Returns the Fusion.Simulation for this NetworkRunner. More...
 
SimulationModes Mode [get]
 Returns the SimulationModes flags for The type of network peer the associated Fusion.Simulation represents. More...
 
SimulationStages Stage [get]
 Returns the current SimulationStages stage of this Fusion.Simulation. More...
 
float DeltaTime [get]
 Returns the fixed tick time interval. Derived from the SimulationConfig.TickRate. More...
 
float SimulationTime [get]
 The time the current State SimulationSnapshot represents (the most recent FixedUpdateNetwork simulation). Use as an equivalent to Unity's Time.fixedTime. Time is relative to Tick 0 (which represents Time 0f). More...
 
float SimulationRenderTime [get]
 The current time (current State.Time + Simulation.DeltaTime) for predicted objects (objects in the local time frame). Use as an equivalent to Unity's Time.time. Time is relative to Tick 0 (which represents Time 0f). More...
 
float InterpolationRenderTime [get]
 The current time (current State.Time + Simulation.DeltaTime) for non-predicted objects (objects in a remote time frame). Use as an equivalent to Unity's Time.time. Time is relative to Tick 0 (which represents Time 0f). More...
 
bool IsRunning [get]
 Returns if this Fusion.Simulation is valid and running. More...
 
bool IsShutdown [get]
 If the runner is shutdown More...
 
bool IsStarting [get]
 If the runner is pending to start More...
 
bool IsClient [get]
 Returns if this Fusion.Simulation represents a Client connection. More...
 
bool IsConnectedToServer [get]
 Returns if this Client is currently connected to a Remote Server More...
 
bool IsServer [get]
 Returns if this Fusion.Simulation represents a Server connection. More...
 
bool IsPlayer [get]
 Returns true if this runner represents a Client or Host. Dedicated servers have no local player and will return false. More...
 
bool IsSinglePlayer [get]
 Returns true if this runner was started as single player (Started as SimulationModes.Host with SimulationConfig.DefaultPlayers = 1). More...
 
bool IsLastTick [get]
 If this is the last tick that is being executed this update More...
 
bool IsFirstTick [get]
 If this is the first tick that executes this update or re-simulation More...
 
bool IsForward [get]
 If this is not a re-simulation but a new forward tick More...
 
bool IsResimulation [get]
 If we are currently executing a client side prediction re-simulation. More...
 
States State [get]
 The current state of the runner, if it's Starting, Running, Shutdown More...
 
PlayerRef LocalPlayer [get]
 Returns a PlayerRef for the local simulation. For a dedicated server PlayerRef.IsValid will equal false. PlayerRefs are assigned in order from 0 to MaxPlayers-1 and are re-used as players join and leave. The only caveat is that the server player (if one exists), always gets the last index no matter how many clients are connected. More...
 
Tick??? Tick [get]
 The tick associated with the current state of networked objects, or the current simulation tick being processed (when evaluated during FixedUpdateNetwork). More...
 
NetworkProjectConfig Config [get]
 Returns the NetworkProjectConfig reference. More...
 
int TicksExecuted [get]
 Returns how many ticks we executed last update. More...
 
IEnumerable< PlayerRefActivePlayers [get]
 Returns the collection of PlayerRef objects for this NetworkRunner's Fusion.Simulation. More...
 
INetworkSceneManager SceneManager [get]
 Returns the INetworkSceneManager instance. More...
 
INetworkObjectPool ObjectPool [get]
 Returns the INetworkObjectPool instance. More...
 
HitboxManager LagCompensation [get]
 Returns the global instance of a lag compensation buffer Fusion.HitboxManager. More...
 
bool IsHostMigrationEnabled [get]
 Signal if Fusion was initilized with Host Migration system enabled More...
 
bool IsResume [get]
 if this instance is a resume (host migration) More...
 
static IReadOnlyList< NetworkRunnerInstances [get]
 A list of all NetworkRunners. More...
 
bool IsCloudReady [get]
 Signal if the Local Peer is connected to Photon Cloud and is able to Create/Join Room but also receive Lobby Updates More...
 
string UserId [get]
 Photon Client UserID More...
 
AuthenticationValues AuthenticationValues [get]
 AuthenticationValues used by this Runner to Authenticate the local peer. More...
 
GameMode GameMode [get]
 Current Game Mode active on the Fusion Simulation More...
 
SessionInfo SessionInfo = new SessionInfo() [get]
 Stores information about the current running session More...
 
LobbyInfo LobbyInfo = new LobbyInfo() [get]
 Signal if the local peer is already inside a Lobby More...
 
ConnectionType CurrentConnectionType [get]
 Check the current Connection Type with the Remote Server More...
 
NATType NATType [get]
 Exposes the current NAT Type from the local Peer More...
 
bool IsSharedModeMasterClient [get]
 Signal if the Local Peer is in a Room and is the Room Master Client More...
 
SceneRef CurrentScene [get]
 Returns the current loaded network scene. More...
 
Scene SimulationUnityScene [get]
 Returns the Unity scene for this NetworkRunner. With NetworkProjectConfig.PeerModes.Multiple, multiple physics scenes may exist, and this getter should be used in place of SceneManager.GetActiveScene(). More...
 
Scene MultiplePeerUnityScene [get, set]
 A scene used when run in NetworkProjectConfig.PeerModes.Multiple mode. More...
 
bool IsMultiplePeerSceneTemp [get]
 Signal if this Runner is already in a Temp Physics Scene More...
 

Detailed Description

Represents a Server or Client Simulation.

All Scene related API and fields

Host Migration related code in order to get a copy of the Simulation State

Member Enumeration Documentation

◆ BuildTypes

enum BuildTypes
strong

Enumeration of Fusion.Runtime.dll options.

Enumerator
Debug 

Use the Debug version of the Fusion.Runntime.dll.

Release 

Use the Debug version of the Fusion.Runntime.dll.

◆ States

enum States
strong

Initialization stages of Fusion

Enumerator
Starting 

Runner is about to start

Running 

Runner is running

Shutdown 

Runner is shutdown

Member Function Documentation

◆ AddCallbacks()

void AddCallbacks ( params INetworkRunnerCallbacks[]  callbacks)

Register an INetworkRunnerCallbacks instance for callbacks from this NetworkRunner.

Parameters
callbacks

◆ AddOrGetGlobal< T >()

T AddOrGetGlobal< T > ( )

Ensures that a specific SimulationBehaviour component exists on this NetworkRunner gameobject.

Type Constraints
T :SimulationBehaviour 

◆ AddPlayerAreaOfInterest()

void AddPlayerAreaOfInterest ( PlayerRef  player,
Vector3  position,
float  extent,
int  layersMask = -1 
)

Adds an area of interest region for a specific player. A player can have multiple areas of interest regions added. These are cleared every tick, so this needs to be called every NetworkBehaviour.FixedUpdateNetwork().

Parameters
playerThe player
positionCenter position of the area of interest
extentThe extents of the area of interest.

◆ AddSimulationBehaviour()

void AddSimulationBehaviour ( SimulationBehaviour  behaviour,
NetworkObject  obj = null 
)

Register a SimulationBehaviour instance with the SimulationBehaviourUpdater. Invalid if NetworkRunner has not been started and initialized.

◆ Attach()

void Attach ( NetworkObject  networkObject,
PlayerRef inputAuthority = null 
)

Attaches a user created network object to the network

Parameters
networkObjectThe object to attach
inputAuthorityIf assigned who is the default input authority for this object

◆ Despawn()

void Despawn ( NetworkObject  networkObject,
bool  allowPredicted = false 
)

Destroys a NetworkObject.

Parameters
networkObject

◆ Disconnect()

void Disconnect ( PlayerRef  player)

Disconnect a player from the server

Parameters
playerPlayer to disconnect

◆ EnsureRunnerSceneIsActive()

bool EnsureRunnerSceneIsActive ( out Scene  previousActiveScene)

If running in NetworkProjectConfig.PeerModes.Multiple peer mode and the current active scene is different than MultiplePeerUnityScene, switches active scene to MultiplePeerUnityScene, stores the previous active scene in previousActiveScene and returns true. Returns false otherwise.

Parameters
previousActiveScene
Returns
True if an actual change occurred.

◆ Exists() [1/2]

bool Exists ( NetworkId  id)

Returns if the Fusion.Simulation contains a NetworkObject with given id in the current State SimulationSnapshot.

◆ Exists() [2/2]

bool Exists ( NetworkObject  obj)

Returns if the Fusion.Simulation contains a reference to a NetworkObject in the current State SimulationSnapshot.

◆ FindObject()

NetworkObject FindObject ( NetworkId  oref)

Get the NetworkObject instance for this NetworkRunner from a NetworkId.

Parameters
oref
Returns
null if object cannot be found.

◆ GetAllBehaviours()

SimulationBehaviour [] GetAllBehaviours ( Type  type)

Returns array of all SimulationBehaviour registered with this NetworkRunner.

Parameters
type
Returns

◆ GetInputForPlayer< T >()

T? GetInputForPlayer< T > ( PlayerRef  player)

Returns the NetworkInput data from player, converted to the indicated INetworkInput.

Type Constraints
T :unmanaged 
T :INetworkInput 

◆ GetInstancesEnumerator()

static List<NetworkRunner>.Enumerator GetInstancesEnumerator ( )
static

Get enumerator for the collection of all NetworkRunners. Allows to enumerate alloc-free.

Returns

◆ GetInterpolationData()

bool GetInterpolationData ( NetworkBehaviour  behaviour,
bool  predicted,
out InterpolationData  data 
)

Gets the InterpolationData for the current SimulationStages stage. For use in the NetworkBehaviour.Render() callback.

Parameters
behaviour
predictedIndicate if the start and end ticks should represent predicted, or state snapshots.
data
Returns

◆ GetPhysicsScene()

PhysicsScene GetPhysicsScene ( )

Get the 3D Physics scene being used by this Runner.

◆ GetPhysicsScene2D()

PhysicsScene2D GetPhysicsScene2D ( )

Get the 2D Physics scene being used by this Runner.

◆ GetPlayerActorId()

int? GetPlayerActorId ( PlayerRef  player)

Gets Player's Actor Number (ID). Only usable in shared mode.

Parameters
playerPlayerRef to get the Actor Number (ID)
Returns
Actor Number associated with the PlayerRef, otherwise null.

◆ GetPlayerConnectionToken()

byte [] GetPlayerConnectionToken ( PlayerRef  player)

Returns a copy of the Connection Token used by a Player when connecting to this Server. Only available on Server. It will return null if running on a Client or the Connection token is missing

Parameters
playerPlayerRef to check for a Connection Token
Returns
Copy of the Connection Token

◆ GetPlayerConnectionType()

ConnectionType GetPlayerConnectionType ( PlayerRef  player)

Return the ConnectionType with a Remote PlayerRef. Valid only when invoked from a Server (NetworkRunner.IsServer)

Parameters
playerRemote Player to check the ConnectionType
Returns
ConnectionType with a PlayerRef

◆ GetPlayerObject()

NetworkObject GetPlayerObject ( PlayerRef  player)

Gets the network object associated with a specific player

Parameters
player
Returns
Network object if one is associated with the player

◆ GetPlayerRtt()

double GetPlayerRtt ( PlayerRef  playerRef)

Returns the player round trip time (ping) in seconds

Parameters
playerRefThe player you want the round trip time for

◆ GetPlayerUserId()

string GetPlayerUserId ( PlayerRef  player)

Gets Player's UserID. Only usable in shared mode.

Parameters
playerPlayerRef to get the UserID
Returns
UserID if valid player found, otherwise null.

◆ GetRawInputForPlayer()

NetworkInput? GetRawInputForPlayer ( PlayerRef  player)

Returns the unconverted unsafe NetworkInput for the indicated player.

◆ GetResumeSnapshotNetworkObjects()

IEnumerable<NetworkObject> GetResumeSnapshotNetworkObjects ( )

Iterate over the old NetworkObjects from the Resume Snapshot

Returns
Iterable list of NetworkObject

◆ GetResumeSnapshotNetworkSceneObjects()

IEnumerable<(NetworkObject, NetworkObjectHeaderPtr)> GetResumeSnapshotNetworkSceneObjects ( )

Iterate over the Scene NetworkObjects from the Resume Snapshot while giving the reference of the old Snapshot data associated with that particular Scene Object

Returns
Iterable list of Scene NetworkObject and Scene Object Header

◆ GetRunnerForGameObject()

static NetworkRunner GetRunnerForGameObject ( GameObject  gameObject)
static

Get the NetworkRunner a GameObject instance belongs to.

Parameters
gameObjectGameObject to check for a NetworkRunner
Returns
NetworkRunner reference, or null if not found

◆ GetRunnerForScene()

static NetworkRunner GetRunnerForScene ( Scene  scene)
static

Get the NetworkRunner from a specific Scene

Parameters
sceneScene to check for a NetworkRunner
Returns
NetworkRunner reference, or null if not found

◆ InstantiateInRunnerScene() [1/2]

GameObject InstantiateInRunnerScene ( GameObject  original)

Instantiates an object in the scene of this runner

◆ InstantiateInRunnerScene() [2/2]

GameObject InstantiateInRunnerScene ( GameObject  original,
Vector3  position,
Quaternion  rotation 
)

Instantiates an object in the scene of this runner

◆ InstantiateInRunnerScene< T >() [1/2]

T InstantiateInRunnerScene< T > ( original)

Instantiates an object in the scene of this runner

Type Constraints
T :Component 

◆ InstantiateInRunnerScene< T >() [2/2]

T InstantiateInRunnerScene< T > ( original,
Vector3  position,
Quaternion  rotation 
)

Instantiates an object in the scene of this runner

Type Constraints
T :Component 

◆ InvokeSceneLoadDone()

void InvokeSceneLoadDone ( )

Invoke INetworkRunnerCallbacks.OnSceneLoadDone(NetworkRunner) on all implementations

◆ InvokeSceneLoadStart()

void InvokeSceneLoadStart ( )

Invoke INetworkRunnerCallbacks.OnSceneLoadStart(NetworkRunner) on all implementations

◆ IsPlayerActive()

bool IsPlayerActive ( PlayerRef  player)

Parameters
player
Returns

◆ IsPlayerValid()

bool IsPlayerValid ( PlayerRef  player)

Parameters
player
Returns

◆ JoinSessionLobby()

async Task<StartGameResult> JoinSessionLobby ( SessionLobby  sessionLobby,
string  lobbyID = null,
AuthenticationValues  authentication = null,
AppSettings  customAppSettings = null 
)

Join the Peer to a specific Lobby, either a prebuild or a custom one

Parameters
sessionLobbyLobby Type to Join
lobbyIDLobby ID
authenticationAuthentication Values used to authenticate this peer
customAppSettingsCustom Photon Application Settings
Returns
Async Task to Join a Session Lobby. Can be used to wait for the process to be finished.

◆ MoveToRunnerScene()

void MoveToRunnerScene ( GameObject  go)

Moves an object to the scene of this runner

Parameters
goObject to move

◆ MoveToRunnerScene< T >()

void MoveToRunnerScene< T > ( component)

Moves an object to the scene of this runner

Template Parameters
T
Parameters
componentComponent of object to move
Type Constraints
T :Component 

◆ OnBeforeSpawned()

delegate void OnBeforeSpawned ( NetworkRunner  runner,
NetworkObject  obj 
)

Delegate type for on before spawned callback

◆ RemoveCallbacks()

void RemoveCallbacks ( params INetworkRunnerCallbacks[]  callbacks)

Unregister an INetworkRunnerCallbacks instance for callbacks from this NetworkRunner.

Parameters
callbacks

◆ RemoveGlobal< T >()

void RemoveGlobal< T > ( )

Removes a specific SimulationBehaviour from this NetworkRunner gameobject, if it exists.

Type Constraints
T :SimulationBehaviour 

◆ RemoveSimulationBehavior()

void RemoveSimulationBehavior ( SimulationBehaviour  behaviour)

Unregister a SimulationBehaviour instance from the SimulationBehaviourUpdater callbacks. Invalid if NetworkRunner has not been started and initialized.

◆ SendReliableDataToPlayer()

void SendReliableDataToPlayer ( PlayerRef  player,
byte[]  data 
)

Send an arbitrary data buffer to a target Player

Parameters
playerPlayer that should receive the buffer
dataBuffer to be sent

◆ SendReliableDataToServer()

void SendReliableDataToServer ( byte[]  data)

Send an arbitrary data buffer to the Server

Parameters
dataBuffer to be sent

◆ SendRpc() [1/2]

void SendRpc ( SimulationMessage *  message)

Sends RPC message. Not meant to be used directly, ILWeaver calls this.

Parameters
message

◆ SendRpc() [2/2]

void SendRpc ( SimulationMessage *  message,
out RpcSendResult  info 
)

Sends RPC message. Not meant to be used directly, ILWeaver calls this.

Parameters
message
info

◆ SetActiveScene()

void SetActiveScene ( SceneRef  scene)

Update the current Active Scene

Parameters
sceneSceneRef to be activated

◆ SetInterestGroup()

void SetInterestGroup ( NetworkObject  obj,
PlayerRef  player,
string  group,
bool  interested 
)

Add or remove Player's interest in a specific named Interest Group for a specific NetworkObject.
SimulationConfig.ReplicationMode must be set to SimulationConfig.StateReplicationModes.EventualConsistency.

◆ SetPlayerAlwaysInterested()

void SetPlayerAlwaysInterested ( PlayerRef  player,
NetworkObject  networkObject,
bool  alwaysInterested 
)

Flags this player as always interested in this object. Means it does not have to be in a players area of interest to be replicated.

Parameters
playerThe player
networkObjectThe object
alwaysInterestedIf he's always interested, or not.

◆ SetPlayerObject()

void SetPlayerObject ( PlayerRef  player,
NetworkObject  networkObject 
)

Sets the network object associated with this player

Parameters
player
networkObject

◆ Shutdown()

Task Shutdown ( bool  destroyGameObject = true,
ShutdownReason  shutdownReason = ShutdownReason.Ok,
bool  forceShutdownProcedure = false 
)

Initiates a Simulation.Dispose.

◆ SinglePlayerContinue()

void SinglePlayerContinue ( )

Continues a paused game in single player

◆ SinglePlayerPause() [1/2]

void SinglePlayerPause ( )

Pauses the game in single player

◆ SinglePlayerPause() [2/2]

void SinglePlayerPause ( bool  paused)

Sets the paused state in a single player

◆ Spawn() [1/6]

NetworkObject Spawn ( GameObject  prefab,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkObjectPredictionKey?  predictionKey = null,
bool  syncPhysics = true 
)

Attempts to network instantiate a NetworkObject using a GameObject. The supplied GameObject must have a NetworkObject component.

Parameters
prefabA GameObject with a NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
predictionKeyNetworkObjectPredictionKey reference
syncPhysicsIf Physics.SyncTransforms and Physics2D.SyncTransforms should be called after setting the network object position and/or rotation , if provided.
Returns
NetworkObject reference, or null if it was not able to spawn the object

◆ Spawn() [2/6]

NetworkObject Spawn ( NetworkObject  prefab,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkObjectPredictionKey?  predictionKey = null,
bool  syncPhysics = true 
)

Attempts to network instantiate a NetworkObject using a NetworkObject prefab. Note: position and rotation values are only used locally for the instantiation of the object, and are not inherently networked. Use NetworkPositionRotation, or any of its derived classes such as NetworkTransform to replicate the initial transform state.

Parameters
prefabPrefab used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
predictionKeyNetworkObjectPredictionKey reference
syncPhysicsIf Physics.SyncTransforms and Physics2D.SyncTransforms should be called after setting the network object position and/or rotation , if provided.
Returns
NetworkObject reference, or null if it was not able to spawn the object

◆ Spawn() [3/6]

NetworkObject Spawn ( NetworkObjectGuid  prefabGuid,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkObjectPredictionKey?  predictionKey = null,
bool  syncPhysics = true 
)

Attempts to network instantiate a NetworkObject using a NetworkObjectGuid Note: position and rotation values are only used locally for the instantiation of the object, and are not inherently networked. Use NetworkPositionRotation, or any of its derived classes such as NetworkTransform to replicate the initial transform state.

Parameters
prefabGuidObject Guid used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
predictionKeyNetworkObjectPredictionKey reference
syncPhysicsIf Physics.SyncTransforms and Physics2D.SyncTransforms should be called after setting the network object position and/or rotation , if provided.
Returns
NetworkObject reference, or null if it was not able to spawn the object

◆ Spawn() [4/6]

NetworkObject Spawn ( NetworkPrefabAsset  prefabAsset,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkObjectPredictionKey?  predictionKey = null 
)

Attempts to network instantiate a NetworkObject using a NetworkPrefabAsset Note: position and rotation values are only used locally for the instantiation of the object, and are not inherently networked. Use NetworkPositionRotation, or any of its derived classes such as NetworkTransform to replicate the initial transform state.

Parameters
prefabAssetPrefab Asset used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
predictionKeyNetworkObjectPredictionKey reference
Returns
NetworkObject reference, or null if it was not able to spawn the object

◆ Spawn() [5/6]

NetworkObject Spawn ( NetworkPrefabId  prefabId,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkObjectPredictionKey?  predictionKey = null,
bool  syncPhysics = true 
)

Attempts to network instantiate a NetworkObject using a NetworkPrefabId Note: position and rotation values are only used locally for the instantiation of the object, and are not inherently networked. Use NetworkPositionRotation, or any of its derived classes such as NetworkTransform to replicate the initial transform state.

Parameters
prefabIdPrefab ID used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
predictionKeyNetworkObjectPredictionKey reference
syncPhysicsIf Physics.SyncTransforms and Physics2D.SyncTransforms should be called after setting the network object position and/or rotation , if provided.
Returns
NetworkObject reference, or null if it was not able to spawn the object

◆ Spawn() [6/6]

NetworkObject Spawn ( NetworkPrefabRef  prefabRef,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkObjectPredictionKey?  predictionKey = null 
)

Attempts to network instantiate a NetworkObject using a NetworkPrefabRef. Note: position and rotation values are only used locally for the instantiation of the object, and are not inherently networked. Use NetworkPositionRotation, or any of its derived classes such as NetworkTransform to replicate the initial transform state.

Parameters
prefabRefPrefab Ref used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
predictionKeyNetworkObjectPredictionKey reference
Returns
NetworkObject reference, or null if it was not able to spawn the object

◆ Spawn< T >()

T Spawn< T > ( prefab,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkObjectPredictionKey?  predictionKey = null,
bool  syncPhysics = true 
)

Attempts to network instantiate a NetworkObject using a Component type that is part of a NetworkObject

Template Parameters
TMust be a Type derived from SimulationBehaviour
Parameters
prefabSimulationBehaviour used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
predictionKeyNetworkObjectPredictionKey reference
syncPhysicsIf Physics.SyncTransforms and Physics2D.SyncTransforms should be called after setting the network object position and/or rotation , if provided.
Returns
NetworkObject reference, or null if it was not able to spawn the object
Type Constraints
T :SimulationBehaviour 

◆ StartGame()

Task<StartGameResult> StartGame ( StartGameArgs  args)

Starts the local Fusion Runner and takes care of all major setup necessary

Parameters
argsCustom arguments used to setup the Fusion Simulation
Returns
Task that can be awaited to chain actions

◆ TryFindBehaviour()

bool TryFindBehaviour ( NetworkBehaviourId  bref,
out NetworkBehaviour  behaviour 
)

Get the NetworkBehaviour instance for this NetworkRunner from a NetworkBehaviourId.

Parameters
bref
behaviour
Returns
True if object was found.

◆ TryFindObject()

bool TryFindObject ( NetworkId  oref,
out NetworkObject  obj 
)

Get the NetworkObject instance for this NetworkRunner from a NetworkId.

Parameters
oref
obj
Returns
True if object was found.

◆ TryGetInputForPlayer< T >()

bool TryGetInputForPlayer< T > ( PlayerRef  player,
out T  input 
)

Outputs the NetworkInput from player, translated to the indicated INetworkInput.

Type Constraints
T :unmanaged 
T :INetworkInput 

◆ TryGetNetworkedBehaviourFromNetworkedObjectRef< T >()

T TryGetNetworkedBehaviourFromNetworkedObjectRef< T > ( NetworkId  id)

Tries to return the first instance of T found on the root of a NetworkObject.

Template Parameters
T
Parameters
id
Returns
Returns the found component. Null if the NetworkObject cannot be found, or if T cannot be found on the GameObject.
Type Constraints
T :NetworkBehaviour 

◆ TryMultiplePeerAssignTempScene()

bool TryMultiplePeerAssignTempScene ( )

Try to create a temp empty scene for PhysicsScene

Returns
false if the runner was on the temp scene already, true otherwise.

Property Documentation

◆ ActivePlayers

IEnumerable<PlayerRef> ActivePlayers
get

Returns the collection of PlayerRef objects for this NetworkRunner's Fusion.Simulation.

◆ AuthenticationValues

AuthenticationValues AuthenticationValues
get

AuthenticationValues used by this Runner to Authenticate the local peer.

◆ BuildType

BuildTypes BuildType
staticget

Get Fusion.Runtime.dll build type.

◆ Config

Returns the NetworkProjectConfig reference.

◆ CurrentConnectionType

ConnectionType CurrentConnectionType
get

Check the current Connection Type with the Remote Server

◆ CurrentScene

SceneRef CurrentScene
get

Returns the current loaded network scene.

◆ DeltaTime

float DeltaTime
get

Returns the fixed tick time interval. Derived from the SimulationConfig.TickRate.

◆ GameMode

Current Game Mode active on the Fusion Simulation

◆ Instances

IReadOnlyList<NetworkRunner> Instances
staticget

A list of all NetworkRunners.

◆ InterpolationRenderTime

float InterpolationRenderTime
get

The current time (current State.Time + Simulation.DeltaTime) for non-predicted objects (objects in a remote time frame). Use as an equivalent to Unity's Time.time. Time is relative to Tick 0 (which represents Time 0f).

◆ IsClient

bool IsClient
get

Returns if this Fusion.Simulation represents a Client connection.

◆ IsCloudReady

bool IsCloudReady
get

Signal if the Local Peer is connected to Photon Cloud and is able to Create/Join Room but also receive Lobby Updates

◆ IsConnectedToServer

bool IsConnectedToServer
get

Returns if this Client is currently connected to a Remote Server

◆ IsFirstTick

bool IsFirstTick
get

If this is the first tick that executes this update or re-simulation

◆ IsForward

bool IsForward
get

If this is not a re-simulation but a new forward tick

◆ IsHostMigrationEnabled

bool IsHostMigrationEnabled
get

Signal if Fusion was initilized with Host Migration system enabled

◆ IsLastTick

bool IsLastTick
get

If this is the last tick that is being executed this update

◆ IsMultiplePeerSceneTemp

bool IsMultiplePeerSceneTemp
get

Signal if this Runner is already in a Temp Physics Scene

◆ IsPlayer

bool IsPlayer
get

Returns true if this runner represents a Client or Host. Dedicated servers have no local player and will return false.

◆ IsResimulation

bool IsResimulation
get

If we are currently executing a client side prediction re-simulation.

◆ IsResume

bool IsResume
get

if this instance is a resume (host migration)

◆ IsRunning

bool IsRunning
get

Returns if this Fusion.Simulation is valid and running.

◆ IsServer

bool IsServer
get

Returns if this Fusion.Simulation represents a Server connection.

◆ IsSharedModeMasterClient

bool IsSharedModeMasterClient
get

Signal if the Local Peer is in a Room and is the Room Master Client

◆ IsShutdown

bool IsShutdown
get

If the runner is shutdown

◆ IsSinglePlayer

bool IsSinglePlayer
get

Returns true if this runner was started as single player (Started as SimulationModes.Host with SimulationConfig.DefaultPlayers = 1).

◆ IsStarting

bool IsStarting
get

If the runner is pending to start

◆ IsVisible

bool IsVisible
getset

Change the visibility of this NetworkRunner when running in Multiple Peer Mode

◆ LagCompensation

HitboxManager LagCompensation
get

Returns the global instance of a lag compensation buffer Fusion.HitboxManager.

◆ LobbyInfo

Signal if the local peer is already inside a Lobby

◆ LocalPlayer

PlayerRef LocalPlayer
get

Returns a PlayerRef for the local simulation. For a dedicated server PlayerRef.IsValid will equal false. PlayerRefs are assigned in order from 0 to MaxPlayers-1 and are re-used as players join and leave. The only caveat is that the server player (if one exists), always gets the last index no matter how many clients are connected.

◆ Mode

SimulationModes Mode
get

Returns the SimulationModes flags for The type of network peer the associated Fusion.Simulation represents.

◆ MultiplePeerUnityScene

Scene MultiplePeerUnityScene
getset

A scene used when run in NetworkProjectConfig.PeerModes.Multiple mode.

◆ NATType

Exposes the current NAT Type from the local Peer

◆ ObjectPool

INetworkObjectPool ObjectPool
get

Returns the INetworkObjectPool instance.

◆ ProvideInput

bool ProvideInput
getset

Indicates if this NetworkRunner is collecting PlayerRef INetworkInput.

◆ SceneManager

INetworkSceneManager SceneManager
get

Returns the INetworkSceneManager instance.

◆ SessionInfo

Stores information about the current running session

◆ Simulation

Returns the Fusion.Simulation for this NetworkRunner.

◆ SimulationRenderTime

float SimulationRenderTime
get

The current time (current State.Time + Simulation.DeltaTime) for predicted objects (objects in the local time frame). Use as an equivalent to Unity's Time.time. Time is relative to Tick 0 (which represents Time 0f).

◆ SimulationTime

float SimulationTime
get

The time the current State SimulationSnapshot represents (the most recent FixedUpdateNetwork simulation). Use as an equivalent to Unity's Time.fixedTime. Time is relative to Tick 0 (which represents Time 0f).

◆ SimulationUnityScene

Scene SimulationUnityScene
get

Returns the Unity scene for this NetworkRunner. With NetworkProjectConfig.PeerModes.Multiple, multiple physics scenes may exist, and this getter should be used in place of SceneManager.GetActiveScene().

◆ Stage

SimulationStages Stage
get

Returns the current SimulationStages stage of this Fusion.Simulation.

◆ State

States State
get

The current state of the runner, if it's Starting, Running, Shutdown

◆ Tick

Tick??? Tick
get

The tick associated with the current state of networked objects, or the current simulation tick being processed (when evaluated during FixedUpdateNetwork).

◆ TicksExecuted

int TicksExecuted
get

Returns how many ticks we executed last update.

◆ Topology

The current topology used

◆ UserId

string UserId
get

Photon Client UserID

Returns null if Peer is not connected to Photon Cloud