Photon Fusion 2.0.0

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

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

Inherits Behaviour, 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 (SimulationBehaviour instance)
 Add and register a SimulationBehaviour to this NetworkRunner. Note: It should NOT be a NetworkBehaviour
 
void AddPlayerAreaOfInterest (PlayerRef player, Vector3 center, float radius)
 Call this every FixedUpdateNetwork to add an area of interest for a player. Should only be called from the Host/Server in Server client mode. Should only be called for the local player in shared mode.
 
void Attach (NetworkObject networkObject, PlayerRef? inputAuthority=null, bool allocate=true, bool? masterClientObjectOverride=null)
 Attaches a user-created network object to the network.
 
void Attach (NetworkObject[] networkObjects, PlayerRef? inputAuthority=null, bool allocate=true, bool? masterClientObjectOverride=null)
 Attach and assign to this NetworkRunner the NetworkObject provided. Used internally from the default implementation of INetworkSceneManager to register scene objects.
 
void ClearPlayerAreaOfInterest (PlayerRef player)
 Clears the area of interest for a player. This can only be called from the server/host.
 
void Despawn (NetworkObject networkObject)
 Destroys a NetworkObject.
 
void DestroySingleton< T > ()
 Removes a specific SimulationBehaviour from this NetworkRunner gameobject, if it exists.
 
void Disconnect (PlayerRef player, byte[] token=null)
 Disconnects a player from the server.
 
bool EnsureRunnerSceneIsActive (out Scene previousActiveScene)
 Ensures the scene of this runner is active and returns the previous active scene.
 
bool Exists (NetworkId id)
 Returns if the Fusion.Simulation contains a NetworkObject with given id in the current State.
 
bool Exists (NetworkObject obj)
 Returns if the Fusion.Simulation contains a reference to a NetworkObject in the current State.
 
NetworkObject FindObject (NetworkId networkId)
 Get the NetworkObject instance for this NetworkRunner from a NetworkId.
 
SimulationBehaviour[] GetAllBehaviours (Type type)
 Returns an array of all SimulationBehaviour instances registered with this NetworkRunner.
 
List< T > GetAllBehaviours< T > ()
 Get a list with all behaviours of the desired type that are registered on the NetworkRunner.
 
void GetAllBehaviours< T > (List< T > result)
 Add on the list all behaviours of the desired type that are registered on the NetworkRunner. Note: The list will not be cleared before adding the results.
 
void GetAreaOfInterestGizmoData (List<(Vector3 center, Vector3 size, int playerCount, int objectCount)> result)
 Populates the provided list with data about the current Area of Interest (AOI) cells. Each element in the list represents one AOI cell.
 
T? GetInputForPlayer< T > (PlayerRef player)
 Returns the NetworkInput data from player, converted to the indicated INetworkInput.
 
SimulationBehaviourListScope GetInterfaceListHead (Type type, int index, out SimulationBehaviour head)
 Get the interface list head.
 
SimulationBehaviour GetInterfaceListNext (SimulationBehaviour behaviour)
 Get the next behaviour.
 
SimulationBehaviour GetInterfaceListPrev (SimulationBehaviour behaviour)
 Get the previous behaviour.
 
int GetInterfaceListsCount (Type type)
 Get the number of interfaces of the desired type that are registered on the behaviour updater.
 
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)
 Return the RpcTargetStatus for a specific player.
 
SceneRef GetSceneRef (GameObject gameObj)
 
SceneRef GetSceneRef (string sceneNameOrPath)
 
GetSingleton< T > ()
 Ensures that a specific SimulationBehaviour component exists on this NetworkRunner gameobject.
 
bool HasAnyActiveConnections ()
 
bool HasSingleton< T > ()
 Returns if a given SimulationBehaviour is present in this NetworkRunner gameobject.
 
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 (in SceneLoadDoneArgs info)
 Invoke INetworkRunnerCallbacks.OnSceneLoadDone(NetworkRunner) on all implementations.
 
void InvokeSceneLoadStart (SceneRef sceneRef)
 Invoke INetworkRunnerCallbacks.OnSceneLoadStart(NetworkRunner) on all implementations.
 
bool? IsInterestedIn (NetworkObject obj, PlayerRef player)
 Test if a player has Interest in a NetworkObject.
 
bool IsPlayerValid (PlayerRef player)
 Checks if the provided player is valid in the current simulation.
 
async Task< StartGameResultJoinSessionLobby (SessionLobby sessionLobby, string lobbyID=null, AuthenticationValues authentication=null, FusionAppSettings customAppSettings=null, bool? useDefaultCloudPorts=false, CancellationToken cancellationToken=default, bool useCachedRegions=false)
 Join the Peer to a specific Lobby, either a prebuild or a custom one.
 
NetworkSceneAsyncOp LoadScene (SceneRef sceneRef, LoadSceneMode loadSceneMode=LoadSceneMode.Single, LocalPhysicsMode localPhysicsMode=LocalPhysicsMode.None, bool setActiveOnLoad=DefaultSetActiveOnLoad)
 Loads a scene.
 
NetworkSceneAsyncOp LoadScene (SceneRef sceneRef, LoadSceneParameters parameters, bool setActiveOnLoad=DefaultSetActiveOnLoad)
 
NetworkSceneAsyncOp LoadScene (string sceneName, LoadSceneMode loadSceneMode=LoadSceneMode.Single, LocalPhysicsMode localPhysicsMode=LocalPhysicsMode.None, bool setActiveOnLoad=DefaultSetActiveOnLoad)
 Loads a scene.
 
NetworkSceneAsyncOp LoadScene (string sceneName, LoadSceneParameters parameters, bool setActiveOnLoad=DefaultSetActiveOnLoad)
 Loads a scene.
 
void MakeDontDestroyOnLoad (GameObject obj)
 Mark an object as DontDestroyOnLoad.
 
bool MoveGameObjectToSameScene (GameObject gameObj, GameObject other)
 Moves a GameObject to the same scene as another GameObject.
 
bool MoveGameObjectToScene (GameObject gameObj, SceneRef sceneRef)
 Moves a GameObject to a specific scene.
 
void MoveToRunnerScene (GameObject instance, SceneRef? targetSceneRef=null)
 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 ObjectDelegate (NetworkRunner runner, NetworkObject obj)
 Delegate type for object callback.
 
delegate void OnBeforeSpawned (NetworkRunner runner, NetworkObject obj)
 Delegate type for on before spawned callback.
 
async Task< bool > PushHostMigrationSnapshot ()
 Compute and send a Host Migration Snapshot to the Photon Cloud.
 
int RegisterSceneObjects (SceneRef scene, NetworkObject[] objects, NetworkSceneLoadId loadId=default)
 Registers scene objects to the network.
 
void RemoveCallbacks (params INetworkRunnerCallbacks[] callbacks)
 Unregister an INetworkRunnerCallbacks instance for callbacks from this NetworkRunner.
 
void RemoveGlobal (SimulationBehaviour instance)
 Removes a specific SimulationBehaviour from this NetworkObject gameobject, if it exists.
 
void RenderInternal ()
 This method is meant to be called by INetworkRunnerUpdater.
 
void SendReliableDataToPlayer (PlayerRef player, ReliableKey key, byte[] data)
 Sends a reliable data buffer to a target player.
 
void SendReliableDataToServer (ReliableKey key, byte[] data)
 Sends a reliable 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 SetAreaOfInterestCellSize (int size)
 Set the area of interest cell size.
 
void SetAreaOfInterestGrid (int x, int y, int z)
 Set the area of interest grid dimensions.
 
void SetBehaviourReplicateTo (NetworkBehaviour behaviour, PlayerRef player, bool replicate)
 Controls if a specific network behaviours state is replicated to a player or not.
 
void SetBehaviourReplicateToAll (NetworkBehaviour behaviour, bool replicate)
 Controls if a specific network behaviours state is replicated to all players or not.
 
bool SetIsSimulated (NetworkObject obj, bool simulate)
 Sets the simulation state for this object, if it takes part in the NetworkFixedUpdate, etc.
 
void SetMasterClient (PlayerRef player)
 Promote a player to be the new master client. Only the master client is able to call this method.
 
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. Only the NetworkObject State Authority can set interest.
 
void SetPlayerObject (PlayerRef player, NetworkObject networkObject)
 Sets the network object associated with this player.
 
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, NetworkSpawnFlags flags=default)
 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, NetworkSpawnFlags flags=default)
 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
NetworkObject Spawn (NetworkObjectGuid prefabGuid, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default)
 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
NetworkObject Spawn (NetworkPrefabId typeId, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default)
 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
NetworkObject Spawn (NetworkPrefabRef prefabRef, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default)
 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
Spawn< T > (T prefab, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default)
 Attempts to network instantiate a NetworkObject using a Component type that is part of a NetworkObject
 
NetworkSpawnOp SpawnAsync (GameObject prefab, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default, NetworkObjectSpawnDelegate onCompleted=null)
 Attempts to network instantiate a NetworkObject using a GameObject. The supplied GameObject must have a NetworkObject component.
 
NetworkSpawnOp SpawnAsync (NetworkObject prefab, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default, NetworkObjectSpawnDelegate onCompleted=null)
 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
NetworkSpawnOp SpawnAsync (NetworkObjectGuid prefabGuid, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default, NetworkObjectSpawnDelegate onCompleted=null)
 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
NetworkSpawnOp SpawnAsync (NetworkPrefabId typeId, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default, NetworkObjectSpawnDelegate onCompleted=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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
NetworkSpawnOp SpawnAsync (NetworkPrefabRef prefabRef, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default, NetworkObjectSpawnDelegate onCompleted=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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
NetworkSpawnOp SpawnAsync< T > (T prefab, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default, NetworkObjectSpawnDelegate onCompleted=null)
 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 behaviourId, out NetworkBehaviour behaviour)
 Get the NetworkBehaviour instance for this NetworkRunner from a NetworkBehaviourId.
 
bool TryFindBehaviour< T > (NetworkBehaviourId id, out T behaviour)
 Try to find a NetworkBehaviour with the provided NetworkBehaviourId.
 
bool TryFindObject (NetworkId objectId, out NetworkObject networkObject)
 Get the NetworkObject instance for this NetworkRunner from a NetworkId.
 
bool TryGetBehaviourStats (List<(Type, BehaviourStats)> result)
 Populate the provided list with all registered behaviours and their BehaviourStats.
 
bool TryGetInputForPlayer< T > (PlayerRef player, out T input)
 Outputs the NetworkInput from player, translated to the indicated INetworkInput.
 
TryGetNetworkedBehaviourFromNetworkedObjectRef< T > (NetworkId networkId)
 Tries to return the first instance of T found on the root of a NetworkObject.
 
NetworkBehaviourId TryGetNetworkedBehaviourId (NetworkBehaviour behaviour)
 Tries to return a NetworkBehaviourId for the NetworkBehaviour provided.
 
NetworkId TryGetObjectRefFromNetworkedBehaviour (NetworkBehaviour behaviour)
 Tries to return the behaviour NetworkId.
 
bool TryGetObjectStats (NetworkId id, out NetworkObjectStats stats)
 Try to get NetworkObjectStats buffer for a NetworkObject from this NetworkRunner.
 
bool TryGetPhysicsInfo (out NetworkPhysicsInfo info)
 Try to get the physics info.
 
bool TryGetPlayerObject (PlayerRef player, out NetworkObject networkObject)
 Try to gets the NetworkObject associated with a specific player.
 
bool TryGetPlayerStats (PlayerRef player, out SimulationConnectionStats stats)
 Try to get SimulationConnectionStats buffer for a player reference from this NetworkRunner.
 
bool TryGetSceneInfo (out NetworkSceneInfo sceneInfo)
 Tries to get the NetworkSceneInfo of this NetworkRunner.
 
bool TryGetSimulationStats (out SimulationStats stats)
 Try to get SimulationStats buffer from this NetworkRunner.
 
bool TrySetPhysicsInfo (NetworkPhysicsInfo info)
 Try to set the physics info.
 
NetworkSpawnStatus TrySpawn (GameObject prefab, out NetworkObject obj, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default)
 Attempts to network instantiate a NetworkObject using a GameObject. The supplied GameObject must have a NetworkObject component.
 
NetworkSpawnStatus TrySpawn (NetworkObject prefab, out NetworkObject obj, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default)
 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
NetworkSpawnStatus TrySpawn (NetworkObjectGuid prefabGuid, out NetworkObject obj, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default)
 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
NetworkSpawnStatus TrySpawn (NetworkPrefabId typeId, out NetworkObject obj, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default)
 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
NetworkSpawnStatus TrySpawn (NetworkPrefabRef prefabRef, out NetworkObject obj, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default)
 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.
 
NetworkSpawnStatus TrySpawn< T > (T prefab, out T obj, Vector3? position=null, Quaternion? rotation=null, PlayerRef? inputAuthority=null, OnBeforeSpawned onBeforeSpawned=null, NetworkSpawnFlags flags=default)
 Attempts to network instantiate a NetworkObject using a Component type that is part of a NetworkObject
 
NetworkSceneAsyncOp UnloadScene (SceneRef sceneRef)
 
NetworkSceneAsyncOp UnloadScene (string sceneName)
 Unloads a scene.
 
void UpdateInternal (double dt)
 This method is meant to be called by INetworkRunnerUpdater.
 
- 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()
 

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.
 
bool CanSpawn [get]
 Signal if the Network Runner can spawn a NetworkObject
 
NetworkProjectConfig Config [get]
 Returns the NetworkProjectConfig reference.
 
ConnectionType CurrentConnectionType [get]
 Check the current Connection Type with the Remote Server.
 
float DeltaTime [get]
 Returns the fixed tick time interval. Derived from the SimulationRuntimeConfig.TickRate.
 
GameMode GameMode [get]
 Current Game Mode active on the Fusion Simulation.
 
static IReadOnlyList< NetworkRunnerInstances [get]
 A list of all NetworkRunners.
 
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 IsLastTick [get]
 If this is the last tick that is being executed this update.
 
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 IsSceneAuthority [get]
 Is this runner responsible for scene management.
 
bool IsSceneManagerBusy [get]
 Signals if the INetworkSceneManager instance assigned to this NetworkRunner is busy with any scene loading operation.
 
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.PlayerCount = 1).
 
bool IsStarting [get]
 If the runner is pending to start.
 
HitboxManager LagCompensation [get]
 Returns the global instance of a lag compensation buffer Fusion.HitboxManager.
 
Tick LatestServerTick [get]
 Get the latest confirmed tick of the server we are aware of.
 
LobbyInfo LobbyInfo = new LobbyInfo() [get]
 Signal if the local peer is already inside a Lobby.
 
float LocalAlpha [get]
 Get the local time alpha value.
 
PlayerRef LocalPlayer [get]
 Returns a PlayerRef for the local simulation. For a dedicated server PlayerRef.IsRealPlayer 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.
 
float LocalRenderTime [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).
 
SimulationModes Mode [get]
 Returns the SimulationModes flags for The type of network peer the associated Fusion.Simulation represents.
 
NATType NATType [get]
 Exposes the current NAT Type from the local Peer.
 
INetworkObjectProvider ObjectProvider [get]
 Returns the INetworkObjectProvider instance.
 
NetworkPrefabTable Prefabs [get]
 Reference to the NetworkPrefabTable.
 
bool ProvideInput [get, set]
 Indicates if this NetworkRunner is collecting PlayerRef INetworkInput.
 
float RemoteRenderTime [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).
 
INetworkSceneManager SceneManager [get]
 Returns the INetworkSceneManager instance.
 
SessionInfo SessionInfo = new SessionInfo() [get]
 Stores information about the current running session.
 
float SimulationTime [get]
 The time the current State 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]
 The main scene of the NetworkRunner or default if not running.
 
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 TickRate [get]
 
int TicksExecuted [get]
 Returns how many ticks we executed last update.
 
Topologies Topology [get]
 The current topology used.
 
string UserId [get]
 Photon Client UserID.
 

Events

ObjectDelegate ObjectAcquired
 Event for object acquired.
 

Detailed Description

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

All Scene related API and fields.

Represents a Server or Client Simulation.

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
callbacksCallbacks to register

◆ Attach()

void Attach ( NetworkObject  networkObject,
PlayerRef inputAuthority = null,
bool  allocate = true,
bool?  masterClientObjectOverride = null 
)

Attaches a user-created network object to the network.

Parameters
networkObjectThe network object to attach. Must not be null and must have a valid NetworkTypeId.
inputAuthorityOptional PlayerRef. If assigned, it will be the default input authority for this object.
allocateOptional boolean. If true, the object will be allocated in memory and attached to the scene object. Default is true.
masterClientObjectOverrideOptional boolean. If provided, it will override the master client object setting. Default is null.
Exceptions
ArgumentNullExceptionThrown when the provided network object is null.
ArgumentExceptionThrown when the provided network object has an invalid NetworkTypeId.

◆ Despawn()

void Despawn ( NetworkObject  networkObject)

Destroys a NetworkObject.

Parameters
networkObjectThe NetworkObject to be destroyed.

This method checks if the local simulation has state authority over the NetworkObject. If it does, it checks if the NetworkObject exists and has state authority. If these conditions are met, it destroys the NetworkObject.

Exceptions
InvalidOperationExceptionThrown when the NetworkObject does not belong to this runner.

◆ DestroySingleton< T >()

void DestroySingleton< T > ( )

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

Type Constraints
T :SimulationBehaviour 

◆ Disconnect()

void Disconnect ( PlayerRef  player,
byte[]  token = null 
)

Disconnects a player from the server.

Parameters
playerThe player to disconnect. Must be a valid PlayerRef.
tokenOptional byte array. If provided, it will be used as the disconnection token.

This method can only be called from the server. If called from a client, an error message will be logged.

◆ EnsureRunnerSceneIsActive()

bool EnsureRunnerSceneIsActive ( out Scene  previousActiveScene)

Ensures the scene of this runner is active and returns the previous active scene.

Parameters
previousActiveScenePrevious active scene
Returns
True if the scene was changed, false otherwise

◆ FindObject()

NetworkObject FindObject ( NetworkId  networkId)

Get the NetworkObject instance for this NetworkRunner from a NetworkId.

Parameters
networkIdNetworkID to look forward
Returns
null if object cannot be found.

◆ GetAllBehaviours()

SimulationBehaviour[] GetAllBehaviours ( Type  type)

Returns an array of all SimulationBehaviour instances registered with this NetworkRunner.

Parameters
typeThe type of the behaviours to be returned.
Returns
An array of SimulationBehaviour instances of the specified type.

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

List< T > GetAllBehaviours< T > ( )

Get a list with all behaviours of the desired type that are registered on the NetworkRunner.

Template Parameters
TSimulationBehaviour type
Returns
The result list
Type Constraints
T :SimulationBehaviour 

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

void GetAllBehaviours< T > ( List< T >  result)

Add on the list all behaviours of the desired type that are registered on the NetworkRunner. Note: The list will not be cleared before adding the results.

Parameters
resultThe list to add the behaviours
Template Parameters
TSimulationBehaviour type
Type Constraints
T :SimulationBehaviour 

◆ GetAreaOfInterestGizmoData()

void GetAreaOfInterestGizmoData ( List<(Vector3 center, Vector3 size, int playerCount, int objectCount)>  result)

Populates the provided list with data about the current Area of Interest (AOI) cells. Each element in the list represents one AOI cell.

Parameters
resultThe list to be populated with AOI cell data. Each tuple in the list contains the center of the AOI cell, its size, the count of players in the cell, and the count of objects in the cell.

◆ GetInputForPlayer< T >()

T? GetInputForPlayer< T > ( PlayerRef  player)

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

Type Constraints
T :unmanaged 
T :INetworkInput 

◆ GetInterfaceListHead()

SimulationBehaviourListScope GetInterfaceListHead ( Type  type,
int  index,
out SimulationBehaviour  head 
)

Get the interface list head.

Parameters
typeThe interface type
indexThe desired index on the list of behaviourList
headThe head reference
Returns
A disposable SimulationBehaviourListScope to be used on an using scope

◆ GetInterfaceListNext()

SimulationBehaviour GetInterfaceListNext ( SimulationBehaviour  behaviour)

Get the next behaviour.

Parameters
behaviourThe reference behaviour to get the next one
Returns
Gives the next behaviour

◆ GetInterfaceListPrev()

SimulationBehaviour GetInterfaceListPrev ( SimulationBehaviour  behaviour)

Get the previous behaviour.

Parameters
behaviourThe reference behaviour to get the previous one
Returns
Gives the previous behaviour

◆ GetInterfaceListsCount()

int GetInterfaceListsCount ( Type  type)

Get the number of interfaces of the desired type that are registered on the behaviour updater.

Parameters
typeThe interface type
Returns
The number of interfaces

◆ 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
playerPlayerRef to get the network object
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

◆ GetSingleton< T >()

T GetSingleton< T > ( )

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

Type Constraints
T :SimulationBehaviour 

◆ HasSingleton< T >()

bool HasSingleton< T > ( )

Returns if a given SimulationBehaviour is present in this NetworkRunner gameobject.

Returns
Returns true if the SimulationBehaviour was found
Type Constraints
T :SimulationBehaviour 

◆ 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 

◆ IsInterestedIn()

bool? IsInterestedIn ( NetworkObject  obj,
PlayerRef  player 
)

Test if a player has Interest in a NetworkObject.

Returns
Returns null if interest cannot be determined (clients without State Authority are not aware of other client's Object Interest)

◆ IsPlayerValid()

bool IsPlayerValid ( PlayerRef  player)

Checks if the provided player is valid in the current simulation.

Parameters
playerThe player reference to be validated.
Returns
Returns true if the player is valid, false otherwise.

◆ JoinSessionLobby()

async Task< StartGameResult > JoinSessionLobby ( SessionLobby  sessionLobby,
string  lobbyID = null,
AuthenticationValues  authentication = null,
FusionAppSettings  customAppSettings = null,
bool?  useDefaultCloudPorts = false,
CancellationToken  cancellationToken = default,
bool  useCachedRegions = false 
)

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

More about matchmaking: https://doc.photonengine.com/en-us/fusion/current/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
cancellationTokenOptional Cancellation Token
useCachedRegionsSignal if the cached regions ping should be used to speed up connection
Returns
Async Task to Join a Session Lobby. Can be used to wait for the process to be finished.

◆ LoadScene() [1/3]

NetworkSceneAsyncOp LoadScene ( SceneRef  sceneRef,
LoadSceneMode  loadSceneMode = LoadSceneMode::Single,
LocalPhysicsMode  localPhysicsMode = LocalPhysicsMode::None,
bool  setActiveOnLoad = DefaultSetActiveOnLoad 
)

Loads a scene.

Parameters
sceneRefReference to the scene to load
loadSceneModeScene load mode
localPhysicsModeScene physics mode
setActiveOnLoadShould the scene be set as active when loaded
Returns
Scene Load operation

◆ LoadScene() [2/3]

NetworkSceneAsyncOp LoadScene ( string  sceneName,
LoadSceneMode  loadSceneMode = LoadSceneMode::Single,
LocalPhysicsMode  localPhysicsMode = LocalPhysicsMode::None,
bool  setActiveOnLoad = DefaultSetActiveOnLoad 
)

Loads a scene.

Parameters
sceneNameName of the scene to load
loadSceneModeScene load mode
localPhysicsModeScene physics mode
setActiveOnLoadShould the scene be set as active when loaded
Returns
Scene Load operation

◆ LoadScene() [3/3]

NetworkSceneAsyncOp LoadScene ( string  sceneName,
LoadSceneParameters  parameters,
bool  setActiveOnLoad = DefaultSetActiveOnLoad 
)

Loads a scene.

Parameters
sceneNameName of the scene to load
parametersParameters to use when loading the scene
setActiveOnLoadShould the scene be set as active when loaded
Returns
Scene Load operation

◆ MakeDontDestroyOnLoad()

void MakeDontDestroyOnLoad ( GameObject  obj)

Mark an object as DontDestroyOnLoad.

Parameters
objObject to mark

◆ MoveGameObjectToSameScene()

bool MoveGameObjectToSameScene ( GameObject  gameObj,
GameObject  other 
)

Moves a GameObject to the same scene as another GameObject.

Parameters
gameObjGame Object to move
otherGame Object to move to the same scene as
Returns
True if the object was moved, false otherwise

◆ MoveGameObjectToScene()

bool MoveGameObjectToScene ( GameObject  gameObj,
SceneRef  sceneRef 
)

Moves a GameObject to a specific scene.

Parameters
gameObjGame Object to move
sceneRefScene to move the object to
Returns
True if the object was moved, false otherwise

◆ MoveToRunnerScene()

void MoveToRunnerScene ( GameObject  instance,
SceneRef targetSceneRef = null 
)

Moves an object to the scene of this runner.

Parameters
instanceObject to move
targetSceneRefTarget scene to move the object to

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

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

◆ RegisterSceneObjects()

int RegisterSceneObjects ( SceneRef  scene,
NetworkObject[]  objects,
NetworkSceneLoadId  loadId = default 
)

Registers scene objects to the network.

Parameters
sceneThe scene reference. Must be valid.
objectsArray of NetworkObject instances to be registered. Must not be null.
loadIdOptional NetworkSceneLoadId. Default value is used if not provided.
Returns
The number of objects registered.
Exceptions
ArgumentExceptionThrown when the provided scene is not valid.
ArgumentNullExceptionThrown when the provided objects array is null.

◆ RemoveCallbacks()

void RemoveCallbacks ( params INetworkRunnerCallbacks[]  callbacks)

Unregister an INetworkRunnerCallbacks instance for callbacks from this NetworkRunner.

Parameters
callbacksCallbacks to unregister

◆ SendReliableDataToPlayer()

void SendReliableDataToPlayer ( PlayerRef  player,
ReliableKey  key,
byte[]  data 
)

Sends a reliable data buffer to a target player.

Parameters
playerThe player who should receive the buffer.
keyThe key associated with the reliable data.
dataThe data buffer to be sent.

◆ SendReliableDataToServer()

void SendReliableDataToServer ( ReliableKey  key,
byte[]  data 
)

Sends a reliable data buffer to the server.

Parameters
keyThe key associated with the reliable data.
dataThe data buffer to be sent.

If the runner is a client, the data is sent to the server (connection index 0) with the player's index. If the runner is a server, the data is sent via the simulation callbacks.

◆ SendRpc() [1/2]

void SendRpc ( SimulationMessage message)

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

Parameters
messageSimulationMessage to send

◆ SendRpc() [2/2]

void SendRpc ( SimulationMessage message,
out RpcSendResult  info 
)

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

Parameters
messageSimulationMessage to send
infoRpcSendResult

◆ SetAreaOfInterestCellSize()

void SetAreaOfInterestCellSize ( int  size)

Set the area of interest cell size.

Parameters
sizeSize of the cell
Exceptions
ExceptionCan't change cell size in shared mode

◆ SetAreaOfInterestGrid()

void SetAreaOfInterestGrid ( int  x,
int  y,
int  z 
)

Set the area of interest grid dimensions.

Parameters
xX dimension
yY dimension
zZ dimension
Exceptions
ExceptionCan't change grid size in shared mode

◆ SetBehaviourReplicateTo()

void SetBehaviourReplicateTo ( NetworkBehaviour  behaviour,
PlayerRef  player,
bool  replicate 
)

Controls if a specific network behaviours state is replicated to a player or not.

Parameters
behaviourThe behaviour to change replication status for
playerThe player to change replication status for
replicatetrue = replicate, false = don't replicate

◆ SetBehaviourReplicateToAll()

void SetBehaviourReplicateToAll ( NetworkBehaviour  behaviour,
bool  replicate 
)

Controls if a specific network behaviours state is replicated to all players or not.

Parameters
behaviourThe behaviour to change replication status for
replicatetrue = replicate, false = don't replicate

◆ SetIsSimulated()

bool SetIsSimulated ( 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

◆ SetMasterClient()

void SetMasterClient ( PlayerRef  player)

Promote a player to be the new master client. Only the master client is able to call this method.

Parameters
playerThe player to be promoted to master client

◆ 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. Only the NetworkObject State Authority can set interest.

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
playerPlayerRef to set the network object
networkObjectNetwork object to associate with the player

◆ Spawn() [1/5]

NetworkObject Spawn ( GameObject  prefab,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default 
)

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
flagsSpawn flags
Returns
NetworkObject reference, or null if it was not able to spawn the object

◆ Spawn() [2/5]

NetworkObject Spawn ( NetworkObject  prefab,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default 
)

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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

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

◆ Spawn() [3/5]

NetworkObject Spawn ( NetworkObjectGuid  prefabGuid,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default 
)

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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

Parameters
prefabGuidObject Guid used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags
Returns
NetworkObject reference, or null if it was not able to spawn the object

◆ Spawn() [4/5]

NetworkObject Spawn ( NetworkPrefabId  typeId,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default 
)

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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

Parameters
typeIdPrefab ID used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags
Returns
NetworkObject reference, or null if it was not able to spawn the object

◆ Spawn() [5/5]

NetworkObject Spawn ( NetworkPrefabRef  prefabRef,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default 
)

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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

Parameters
prefabRefPrefab Ref used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags
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,
NetworkSpawnFlags  flags = default 
)

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
Returns
T reference, or null if it was not able to spawn the object
Parameters
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags
Type Constraints
T :SimulationBehaviour 

◆ SpawnAsync() [1/5]

NetworkSpawnOp SpawnAsync ( GameObject  prefab,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default,
NetworkObjectSpawnDelegate  onCompleted = null 
)

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
flagsSpawn flags

,

Parameters
onCompletedA callback to fire once the spawn is done.

◆ SpawnAsync() [2/5]

NetworkSpawnOp SpawnAsync ( NetworkObject  prefab,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default,
NetworkObjectSpawnDelegate  onCompleted = null 
)

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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

Parameters
prefabPrefab used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags

,

Parameters
onCompletedA callback to fire once the spawn is done.

◆ SpawnAsync() [3/5]

NetworkSpawnOp SpawnAsync ( NetworkObjectGuid  prefabGuid,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default,
NetworkObjectSpawnDelegate  onCompleted = null 
)

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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

Parameters
prefabGuidObject Guid used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags

,

Parameters
onCompletedA callback to fire once the spawn is done.

◆ SpawnAsync() [4/5]

NetworkSpawnOp SpawnAsync ( NetworkPrefabId  typeId,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default,
NetworkObjectSpawnDelegate  onCompleted = 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

Parameters
typeIdPrefab ID used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags

,

Parameters
onCompletedA callback to fire once the spawn is done.

◆ SpawnAsync() [5/5]

NetworkSpawnOp SpawnAsync ( NetworkPrefabRef  prefabRef,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default,
NetworkObjectSpawnDelegate  onCompleted = 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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

Parameters
prefabRefPrefab Ref used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags

,

Parameters
onCompletedA callback to fire once the spawn is done.

◆ SpawnAsync< T >()

NetworkSpawnOp SpawnAsync< T > ( prefab,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default,
NetworkObjectSpawnDelegate  onCompleted = null 
)

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
Returns
T reference, or null if it was not able to spawn the object
Parameters
onCompletedA callback to fire once the spawn is done.
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags
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/en-us/fusion/current/manual/matchmaking

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

◆ TryFindBehaviour()

bool TryFindBehaviour ( NetworkBehaviourId  behaviourId,
out NetworkBehaviour  behaviour 
)

Get the NetworkBehaviour instance for this NetworkRunner from a NetworkBehaviourId.

Parameters
behaviourIdNetworkBehaviourId to look forward
behaviourNetworkBehaviour reference, if found
Returns
True if object was found.

◆ TryFindBehaviour< T >()

bool TryFindBehaviour< T > ( NetworkBehaviourId  id,
out T  behaviour 
)

Try to find a NetworkBehaviour with the provided NetworkBehaviourId.

Parameters
idThe NetworkBehaviourId to search for
behaviourThe behaviour found
Template Parameters
TA NetworkBehaviour type
Returns
Returns true if the behaviour was found and it is alive. False otherwise
Type Constraints
T :NetworkBehaviour 

◆ TryFindObject()

bool TryFindObject ( NetworkId  objectId,
out NetworkObject  networkObject 
)

Get the NetworkObject instance for this NetworkRunner from a NetworkId.

Parameters
objectIdObject NetworkID to look forward
networkObjectNetworkObject reference, if found
Returns
True if object was found.

◆ TryGetBehaviourStats()

bool TryGetBehaviourStats ( List<(Type, BehaviourStats)>  result)

Populate the provided list with all registered behaviours and their BehaviourStats.

Parameters
resultThe list to be populated
Returns
Returns true if at least one item is added to the list

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

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

Template Parameters
TThe type of the component to search for
Parameters
networkIdNetworkId of the NetworkObject to search for
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 

◆ TryGetNetworkedBehaviourId()

NetworkBehaviourId TryGetNetworkedBehaviourId ( NetworkBehaviour  behaviour)

Tries to return a NetworkBehaviourId for the NetworkBehaviour provided.

Parameters
behaviourNetworkBehaviour to get the NetworkBehaviourId from
Returns
Returns a NetworkBehaviourId to the provided behaviour. Returns default if the behaviour is not alive or the NetworkObject that has this behaviour is not valid.

◆ TryGetObjectRefFromNetworkedBehaviour()

NetworkId TryGetObjectRefFromNetworkedBehaviour ( NetworkBehaviour  behaviour)

Tries to return the behaviour NetworkId.

Parameters
behaviourNetworkBehaviour to get the NetworkId from
Returns
Returns the NetworkId of the provided behaviour. Returns default if the behaviour is not alive or the NetworkObject that has this behaviour is not valid.

◆ TryGetObjectStats()

bool TryGetObjectStats ( NetworkId  id,
out NetworkObjectStats  stats 
)

Try to get NetworkObjectStats buffer for a NetworkObject from this NetworkRunner.

Returns
Returns false if stats were not available.

◆ TryGetPhysicsInfo()

bool TryGetPhysicsInfo ( out NetworkPhysicsInfo  info)

Try to get the physics info.

Parameters
infoNetwork physics info
Returns
True if the physics info exists, otherwise false.

◆ TryGetPlayerObject()

bool TryGetPlayerObject ( PlayerRef  player,
out NetworkObject  networkObject 
)

Try to gets the NetworkObject associated with a specific player.

Parameters
playerPlayerRef to get the network object
networkObjectNetwork object if one is associated with the player
Returns
Signals if it was able to get a NetworkObject for the player provided

◆ TryGetPlayerStats()

bool TryGetPlayerStats ( PlayerRef  player,
out SimulationConnectionStats  stats 
)

Try to get SimulationConnectionStats buffer for a player reference from this NetworkRunner.

Returns
Returns false if stats were not available.

◆ TryGetSceneInfo()

bool TryGetSceneInfo ( out NetworkSceneInfo  sceneInfo)

Tries to get the NetworkSceneInfo of this NetworkRunner.

Parameters
sceneInfoThe result NetworkSceneInfo
Returns
Returns true if it was able to get the scene info

◆ TryGetSimulationStats()

bool TryGetSimulationStats ( out SimulationStats  stats)

Try to get SimulationStats buffer from this NetworkRunner.

Returns
Returns false if stats were not available.

◆ TrySetPhysicsInfo()

bool TrySetPhysicsInfo ( NetworkPhysicsInfo  info)

Try to set the physics info.

Parameters
infoNetwork physics info
Returns
True if the physics info was set, otherwise false.
Exceptions
InvalidOperationExceptionThrown if the runner does not have the scene authority.

◆ TrySpawn() [1/5]

NetworkSpawnStatus TrySpawn ( GameObject  prefab,
out NetworkObject  obj,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default 
)

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
flagsSpawn flags
objSpawned NetworkObject reference
Returns
NetworkSpawnStatus reference, or null if it was not able to spawn the object

◆ TrySpawn() [2/5]

NetworkSpawnStatus TrySpawn ( NetworkObject  prefab,
out NetworkObject  obj,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default 
)

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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

Parameters
prefabPrefab used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags
objSpawned NetworkObject reference
Returns
NetworkSpawnStatus reference, or null if it was not able to spawn the object

◆ TrySpawn() [3/5]

NetworkSpawnStatus TrySpawn ( NetworkObjectGuid  prefabGuid,
out NetworkObject  obj,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default 
)

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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

Parameters
prefabGuidObject Guid used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags
objSpawned NetworkObject reference
Returns
NetworkSpawnStatus reference, or null if it was not able to spawn the object

◆ TrySpawn() [4/5]

NetworkSpawnStatus TrySpawn ( NetworkPrefabId  typeId,
out NetworkObject  obj,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default 
)

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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

Parameters
typeIdPrefab ID used to spawn the NetworkObject
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags
objSpawned NetworkObject reference
Returns
NetworkSpawnStatus reference, or null if it was not able to spawn the object

◆ TrySpawn() [5/5]

NetworkSpawnStatus TrySpawn ( NetworkPrefabRef  prefabRef,
out NetworkObject  obj,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default 
)

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 NetworkTransform (or any custom class derived from NetworkTRSP) to replicate the initial transform state.

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

◆ TrySpawn< T >()

NetworkSpawnStatus TrySpawn< T > ( prefab,
out T  obj,
Vector3?  position = null,
Quaternion?  rotation = null,
PlayerRef inputAuthority = null,
OnBeforeSpawned  onBeforeSpawned = null,
NetworkSpawnFlags  flags = default 
)

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
Returns
T reference, or null if it was not able to spawn the object
Parameters
objSpawned NetworkObject reference
positionSpawn Position
rotationSpawn Rotation
inputAuthorityPlayer Input Authority
onBeforeSpawnedOnBeforeSpawned reference
flagsSpawn flags
Type Constraints
T :SimulationBehaviour 

◆ UnloadScene()

NetworkSceneAsyncOp UnloadScene ( string  sceneName)

Unloads a scene.

Parameters
sceneNameName of the scene to unload
Returns
Scene Unload operation

Property Documentation

◆ UserId

string UserId
get

Photon Client UserID.

Returns null if Peer is not connected to Photon Cloud