Photon Fusion 1.1.9

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, and Simulation.ICallbacks.

Public Types

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

Public Member Functions

void AddCallbacks (params INetworkRunnerCallbacks[] callbacks)
 Register an INetworkRunnerCallbacks instance for callbacks from this NetworkRunner.
 
void AddGlobal< T > ()
 
AddOrGetGlobal< T > ()
 Ensures that a specific SimulationBehaviour component exists on this NetworkRunner gameobject.
 
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().
 
void AddSimulationBehaviour (SimulationBehaviour behaviour, NetworkObject obj=null)
 Register a SimulationBehaviour instance with the SimulationBehaviourUpdater. Invalid if NetworkRunner has not been started and initialized.
 
void Attach (NetworkObject networkObject, PlayerRef? inputAuthority=null)
 Attaches a user created network object to the network.
 
void Despawn (NetworkObject networkObject, bool allowPredicted=false)
 Destroys a NetworkObject.
 
void Disconnect (PlayerRef player)
 Disconnect a player from the server.
 
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.
 
bool Exists (NetworkId id)
 Returns if the Fusion.Simulation contains a NetworkObject with given id in the current State SimulationSnapshot.
 
bool Exists (NetworkObject obj)
 Returns if the Fusion.Simulation contains a reference to a NetworkObject in the current State SimulationSnapshot.
 
NetworkObject FindObject (NetworkId oref)
 Get the NetworkObject instance for this NetworkRunner from a NetworkId.
 
SimulationBehaviour[] GetAllBehaviours (Type type)
 Returns array of all SimulationBehaviour registered with this NetworkRunner.
 
List< T > GetAllBehaviours< T > ()
 
void GetAllBehaviours< T > (List< T > result)
 
GetGlobal< T > ()
 
int GetHashCodeForLogger ()
 
T? GetInputForPlayer< T > (PlayerRef player)
 Returns the NetworkInput data from player, converted to the indicated INetworkInput.
 
SimulationBehaviour GetInterfaceListHead (Type type, int index)
 
SimulationBehaviourListScope GetInterfaceListHead (Type type, int index, out SimulationBehaviour head)
 
SimulationBehaviour GetInterfaceListNext (SimulationBehaviour behaviour)
 
SimulationBehaviour GetInterfaceListPrev (SimulationBehaviour behaviour)
 
int GetInterfaceListsCount (Type type)
 
bool GetInterpolationData (NetworkBehaviour behaviour, bool predicted, out InterpolationData data)
 Gets the InterpolationData for the current SimulationStages stage. For use in the NetworkBehaviour.Render() callback.
 
PhysicsScene GetPhysicsScene ()
 Get the 3D Physics scene being used by this Runner.
 
PhysicsScene2D GetPhysicsScene2D ()
 Get the 2D Physics scene being used by this Runner.
 
int? GetPlayerActorId (PlayerRef player)
 Gets Player's Actor Number (ID).
 
byte[] GetPlayerConnectionToken (PlayerRef player=default)
 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.
 
ConnectionType GetPlayerConnectionType (PlayerRef player)
 Return the ConnectionType with a Remote PlayerRef. Valid only when invoked from a Server (NetworkRunner.IsServer)
 
NetworkObject GetPlayerObject (PlayerRef player)
 Gets the network object associated with a specific player.
 
double GetPlayerRtt (PlayerRef playerRef)
 Returns the player round trip time (ping) in seconds.
 
string GetPlayerUserId (PlayerRef player=default)
 Gets Player's UserID.
 
NetworkInputGetRawInputForPlayer (PlayerRef player)
 Returns the unconverted unsafe NetworkInput for the indicated player.
 
IEnumerable< NetworkObjectGetResumeSnapshotNetworkObjects ()
 Iterate over the old NetworkObjects from the Resume Snapshot.
 
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.
 
RpcTargetStatus GetRpcTargetStatus (PlayerRef target)
 
bool HasAnyActiveConnections ()
 
GameObject InstantiateInRunnerScene (GameObject original)
 Instantiates an object in the scene of this runner.
 
GameObject InstantiateInRunnerScene (GameObject original, Vector3 position, Quaternion rotation)
 Instantiates an object in the scene of this runner.
 
InstantiateInRunnerScene< T > (T original)
 Instantiates an object in the scene of this runner.
 
InstantiateInRunnerScene< T > (T original, Vector3 position, Quaternion rotation)
 Instantiates an object in the scene of this runner.
 
void InvokeSceneLoadDone ()
 Invoke INetworkRunnerCallbacks.OnSceneLoadDone(NetworkRunner) on all implementations.
 
void InvokeSceneLoadStart ()
 Invoke INetworkRunnerCallbacks.OnSceneLoadStart(NetworkRunner) on all implementations.
 
bool IsPlayerActive (PlayerRef player)
 
bool IsPlayerValid (PlayerRef player)
 
async Task< StartGameResultJoinSessionLobby (SessionLobby sessionLobby, string lobbyID=null, AuthenticationValues authentication=null, AppSettings customAppSettings=null, bool? useDefaultCloudPorts=false)
 Join the Peer to a specific Lobby, either a prebuild or a custom one.
 
void MoveToRunnerScene (GameObject go)
 Moves an object to the scene of this runner.
 
void MoveToRunnerScene< T > (T component)
 Moves an object to the scene of this runner.
 
delegate void OnBeforeSpawned (NetworkRunner runner, NetworkObject obj)
 Delegate type for on before spawned callback.
 
Task< bool > PushHostMigrationSnapshot ()
 Compute and send a Host Migration Snapshot to the Photon Cloud.
 
void RegisterSceneObjects (IEnumerable< NetworkObject > objects)
 
void RegisterUniqueObjects (IEnumerable< NetworkObject > objects)
 
void RemoveCallbacks (params INetworkRunnerCallbacks[] callbacks)
 Unregister an INetworkRunnerCallbacks instance for callbacks from this NetworkRunner.
 
void RemoveGlobal< T > ()
 Removes a specific SimulationBehaviour from this NetworkRunner gameobject, if it exists.
 
void RemoveSimulationBehavior (SimulationBehaviour behaviour)
 Unregister a SimulationBehaviour instance from the SimulationBehaviourUpdater callbacks. Invalid if NetworkRunner has not been started and initialized.
 
void SendReliableDataToPlayer (PlayerRef player, byte[] data)
 Send an arbitrary data buffer to a target Player.
 
void SendReliableDataToServer (byte[] data)
 Send an arbitrary data buffer to the Server.
 
void SendRpc (SimulationMessage *message)
 Sends RPC message. Not meant to be used directly, ILWeaver calls this.
 
void SendRpc (SimulationMessage *message, out RpcSendResult info)
 Sends RPC message. Not meant to be used directly, ILWeaver calls this.
 
void SetActiveScene (SceneRef scene)
 Update the current Active Scene.
 
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.
 
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.
 
void SetPlayerObject (PlayerRef player, NetworkObject networkObject)
 Sets the network object associated with this player.
 
bool SetSimulationState (NetworkObject obj, bool simulate)
 Sets the simulation state for this object, if it takes part in the NetworkFixedUpdate, etc.
 
Task Shutdown (bool destroyGameObject=true, ShutdownReason shutdownReason=ShutdownReason.Ok, bool forceShutdownProcedure=false)
 Initiates a Simulation.Dispose.
 
void SinglePlayerContinue ()
 Continues a paused game in single player.
 
void SinglePlayerPause ()
 Pauses the game in single player.
 
void SinglePlayerPause (bool paused)
 Sets the paused state in a single player.
 
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.
 
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.
 
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.
 
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.
 
NetworkObject Spawn (NetworkPrefabId prefabId, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkObjectPredictionKey? predictionKey=null, bool syncPhysics=true, NetworkObject resumeNO=null)
 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.
 
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.
 
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
 
Task< StartGameResultStartGame (StartGameArgs args)
 Starts the local Fusion Runner and takes care of all major setup necessary.
 
bool TryFindBehaviour (NetworkBehaviourId bref, out NetworkBehaviour behaviour)
 Get the NetworkBehaviour instance for this NetworkRunner from a NetworkBehaviourId.
 
bool TryFindBehaviour< T > (NetworkBehaviourId id, out T behaviour)
 
bool TryFindObject (NetworkId oref, out NetworkObject obj)
 Get the NetworkObject instance for this NetworkRunner from a NetworkId.
 
bool TryGetInputForPlayer< T > (PlayerRef player, out T input)
 Outputs the NetworkInput from player, translated to the indicated INetworkInput.
 
TryGetNetworkedBehaviourFromNetworkedObjectRef< T > (NetworkId id)
 Tries to return the first instance of T found on the root of a NetworkObject.
 
NetworkBehaviourId TryGetNetworkedBehaviourId (NetworkBehaviour behaviour)
 
NetworkId TryGetObjectRefFromNetworkedBehaviour (NetworkBehaviour behaviour)
 
bool TryGetPlayerObject (PlayerRef player, out NetworkObject networkObject)
 
bool TryMultiplePeerAssignTempScene ()
 Try to create a temp empty scene for PhysicsScene.
 
- Public Member Functions inherited from Behaviour
AddBehaviour< T > ()
 Wrapper for Unity's GameObject.AddComponent()
 
GetBehaviour< T > ()
 Wrapper for Unity's GameObject.GetComponentInChildren()
 
bool TryGetBehaviour< T > (out T behaviour)
 Wrapper for Unity's GameObject.TryGetComponent()
 

Static Public Member Functions

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

Static Public Attributes

static Simulation.IDeltaCompressor BurstDeltaCompressor
 

Properties

IEnumerable< PlayerRefActivePlayers [get]
 Returns the collection of PlayerRef objects for this NetworkRunner's Fusion.Simulation.
 
AuthenticationValues AuthenticationValues [get]
 AuthenticationValues used by this Runner to Authenticate the local peer.
 
static BuildTypes BuildType [get]
 Get Fusion.Runtime.dll build type.
 
NetworkProjectConfig Config [get]
 Returns the NetworkProjectConfig reference.
 
ConnectionType CurrentConnectionType [get]
 Check the current Connection Type with the Remote Server.
 
SceneRef CurrentScene [get]
 Returns the current loaded network scene.
 
float DeltaTime [get]
 Returns the fixed tick time interval. Derived from the SimulationConfig.TickRate.
 
GameMode GameMode [get]
 Current Game Mode active on the Fusion Simulation.
 
static IReadOnlyList< NetworkRunnerInstances [get]
 A list of all NetworkRunners.
 
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).
 
bool IsClient [get]
 Returns if this Fusion.Simulation represents a Client connection.
 
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.
 
bool IsConnectedToServer [get]
 Returns if this Client is currently connected to a Remote Server.
 
bool IsFirstTick [get]
 If this is the first tick that executes this update or re-simulation.
 
bool IsForward [get]
 If this is not a re-simulation but a new forward tick.
 
bool IsHostMigrationEnabled [get]
 Signal if Fusion was initilized with Host Migration system enabled.
 
bool IsLastTick [get]
 If this is the last tick that is being executed this update.
 
bool IsMultiplePeerSceneTemp [get]
 Signal if this Runner is already in a Temp Physics Scene.
 
bool IsPlayer [get]
 Returns true if this runner represents a Client or Host. Dedicated servers have no local player and will return false.
 
bool IsResimulation [get]
 If we are currently executing a client side prediction re-simulation.
 
bool IsResume [get]
 if this instance is a resume (host migration)
 
bool IsRunning [get]
 Returns if this Fusion.Simulation is valid and running.
 
bool IsServer [get]
 Returns if this Fusion.Simulation represents a Server connection.
 
bool IsSharedModeMasterClient [get]
 Signal if the Local Peer is in a Room and is the Room Master Client.
 
bool IsShutdown [get]
 If the runner is shutdown.
 
bool IsSinglePlayer [get]
 Returns true if this runner was started as single player (Started as SimulationModes.Host with SimulationConfig.DefaultPlayers = 1).
 
bool IsStarting [get]
 If the runner is pending to start.
 
bool IsVisible [get, set]
 Change the visibility of this NetworkRunner when running in Multiple Peer Mode.
 
HitboxManager LagCompensation [get]
 Returns the global instance of a lag compensation buffer Fusion.HitboxManager.
 
LobbyInfo LobbyInfo = new LobbyInfo() [get]
 Signal if the local peer is already inside a Lobby.
 
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.
 
SimulationModes Mode [get]
 Returns the SimulationModes flags for The type of network peer the associated Fusion.Simulation represents.
 
Scene MultiplePeerUnityScene [get, set]
 A scene used when run in NetworkProjectConfig.PeerModes.Multiple mode.
 
NATType NATType [get]
 Exposes the current NAT Type from the local Peer.
 
INetworkObjectPool ObjectPool [get]
 Returns the INetworkObjectPool instance.
 
bool ProvideInput [get, set]
 Indicates if this NetworkRunner is collecting PlayerRef INetworkInput.
 
INetworkSceneManager SceneManager [get]
 Returns the INetworkSceneManager instance.
 
SessionInfo SessionInfo = new SessionInfo() [get]
 Stores information about the current running session.
 
Simulation Simulation [get]
 Returns the Fusion.Simulation for this NetworkRunner.
 
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).
 
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).
 
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().
 
SimulationStages Stage [get]
 Returns the current SimulationStages stage of this Fusion.Simulation.
 
States State [get]
 The current state of the runner, if it's Starting, Running, Shutdown.
 
Tick Tick [get]
 The tick associated with the current state of networked objects, or the current simulation tick being processed (when evaluated during FixedUpdateNetwork).
 
int TicksExecuted [get]
 Returns how many ticks we executed last update.
 
SimulationConfig.Topologies Topology [get]
 The current topology used.
 
string UserId [get]
 Photon Client UserID.
 

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

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

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

◆ AddGlobal< T >()

void AddGlobal< T > ( )
Type Constraints
T :SimulationBehaviour 

◆ 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.

◆ 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.

◆ 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

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

List< T > GetAllBehaviours< T > ( )
Type Constraints
T :SimulationBehaviour 

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

void GetAllBehaviours< T > ( List< T >  result)
Type Constraints
T :SimulationBehaviour 

◆ GetGlobal< T >()

T GetGlobal< T > ( )
Type Constraints
T :SimulationBehaviour 

◆ 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

◆ GetPlayerActorId()

int? GetPlayerActorId ( PlayerRef  player)

Gets Player's Actor Number (ID).

If used in Shared Mode, every client can get this information. If used in Client Server Mode, only the Server is able to get this information.

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

◆ GetPlayerConnectionToken()

byte[] GetPlayerConnectionToken ( PlayerRef  player = default)

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 = default)

Gets Player's UserID.

If used in Shared Mode, every client can get this information. If used in Client Server Mode, only the Server is able to get this information.

Parameters
playerPlayerRef to get the UserID. If no PlayerRef is passed, the UserID of the local client is returned instead.
Returns
UserID if valid player found, otherwise null.

◆ 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< 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 

◆ 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,
bool?  useDefaultCloudPorts = false 
)

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

More about matchmaking: https://doc.photonengine.com/fusion/v1/manual/matchmaking

Parameters
sessionLobbyLobby Type to Join
lobbyIDLobby ID
authenticationAuthentication Values used to authenticate this peer
customAppSettingsCustom Photon Application Settings
useDefaultCloudPortsSignal if the LoadBalancingClient should use the Default or Alternative Ports
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 

◆ PushHostMigrationSnapshot()

Task< bool > PushHostMigrationSnapshot ( )

Compute and send a Host Migration Snapshot to the Photon Cloud.

Returns
Task with the result of the operation. True if it was successful, false otherwise.

◆ 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 

◆ 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

◆ 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

◆ SetSimulationState()

bool SetSimulationState ( NetworkObject  obj,
bool  simulate 
)

Sets the simulation state for this object, if it takes part in the NetworkFixedUpdate, etc.

Parameters
objthe object to change state for
simulatetrue if it should be simulated, false if otherwise
Returns
true if the state of the object changed, false otherwise

◆ 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,
NetworkObject  resumeNO = null 
)

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.
resumeNOUsed as reference when re-creating the NetworkObject from a old simulation. Accepted only when resuming from a Host Migration.
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.

More about matchmaking: https://doc.photonengine.com/fusion/v1/manual/matchmaking

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.

◆ TryFindBehaviour< T >()

bool TryFindBehaviour< T > ( NetworkBehaviourId  id,
out T  behaviour 
)
Type Constraints
T :NetworkBehaviour 

◆ 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

◆ UserId

string UserId
get

Photon Client UserID.

Returns null if Peer is not connected to Photon Cloud