Photon Fusion 1.1.12

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Properties | List of all members
NetworkObject Class Reference

The primary Fusion component for networked GameObject entities. This stores the object's network identity and manages the object's state and input authority. More...

Inherits Behaviour, and ILogBuilder.

Public Member Functions

void AssignInputAuthority (PlayerRef player)
 Sets which PlayerRef has Input Authority for this Object. More...
 
void CopyStateFrom (NetworkObject source)
 Copies the entire State from another NetworkObject More...
 
void CopyStateFromSceneObject (NetworkObjectHeaderPtr source)
 Copies the entire State from another Scene NetworkObject. They must have the same Scene Guid. More...
 
int GetLocalAuthorityMask ()
 Gets a bitmask of AuthorityMasks flags, representing the current local authority over this NetworkObject. More...
 
void ReleaseStateAuthority ()
 
void RemoveInputAuthority ()
 Removes input authority from whichever player has it for this object. Only valid when called on a Host or Server peer. More...
 
void RequestStateAuthority ()
 
void SetInterestGroup (PlayerRef player, string group, bool interested)
 Add or remove Player's interest in a specific named Interest Group for this NetworkObject. More...
 
void SetPlayerAlwaysInterested (PlayerRef player, bool alwaysInterested)
 Add or remove specific player interest in this NetworkObject. More...
 
- Public Member Functions inherited from Behaviour
AddBehaviour< T > ()
 Wrapper for Unity's GameObject.AddComponent() More...
 
GetBehaviour< T > ()
 Wrapper for Unity's GameObject.GetComponentInChildren() More...
 
bool TryGetBehaviour< T > (out T behaviour)
 Wrapper for Unity's GameObject.TryGetComponent() More...
 

Static Public Member Functions

static void NetworkUnwrap (NetworkRunner runner, NetworkId wrapper, ref NetworkObject result)
 
static NetworkId NetworkWrap (NetworkRunner runner, NetworkObject obj)
 
static implicit operator NetworkId (NetworkObject obj)
 
- Static Public Member Functions inherited from Behaviour
static void DestroyBehaviour (Behaviour behaviour)
 Wrapper for Unity's GameObject.Destroy() More...
 

Public Attributes

NetworkObjectFlags Flags
 Flags used for network object prefabs and similar More...
 
NetworkId Id
 The unique identifier for this network entity. More...
 
bool IsResume
 Signal that this NetworkObject comes from a Resume Spawn More...
 
NetworkObject[] NestedObjects
 Array of initial child nested NetworkObject entities, that are children of this Object. More...
 
NetworkBehaviour[] NetworkedBehaviours
 Array of all NetworkBehaviours associated with this network entity. More...
 
NetworkObjectGuid NetworkGuid
 The GUID for this prefab or scene object, which is set at development time. Used to reference this as a spawnable object. All spawned instances of this object will retain this GUID. Use NetworkId for the unique ID of network entries. More...
 
PredictionData PredictedSpawn
 
NetworkRunner Runner
 The NetworkRunner this entity is associated with. More...
 
SimulationBehaviour[] SimulationBehaviours
 Array of all SimulationBehaviours associated with this network entity. This does not include NetworkBehaviour derived classes, as they are stored in NetworkedBehaviours. More...
 

Static Public Attributes

const int DefaultExecutionOrder = 500
 

Protected Member Functions

virtual void Awake ()
 
virtual void OnDestroy ()
 

Properties

int AreaOfInterestLayerMask [get]
 The layers this object exists in for area of interest queries. This is an integer bitmask not a layer index. More...
 
bool HasInputAuthority [get]
 Returns if Simulation.LocalPlayer is the designated Input Authority for this network entity. More...
 
bool HasStateAuthority [get]
 Returns if Simulation.LocalPlayer is the designated State Authority for this network entity. More...
 
PlayerRef InputAuthority [get]
 Returns the PlayerRef that has Input Authority over this network entity. PlayerRefs are assigned in order from 0 to MaxPlayers-1 and are re-used as players join and leave. The only caveat is that the server player (if one exists), always gets the last index no matter how many clients are connected. More...
 
bool IsInSimulation [get]
 If this object is inserted into the simulation More...
 
bool IsPredictedDespawn [get]
 If this is a predicted spawned object More...
 
bool IsPredictedSpawn [get]
 If this is a predicted spawned object More...
 
bool IsProxy [get]
 Returns if Simulation.LocalPlayer is neither the Input nor State Authority for this network entity. More...
 
bool IsSceneObject [get]
 Returns true if this network entity existed as part of a scene, rather than having been dynamically spawned. More...
 
bool IsSpawnable [get, set]
 Toggles if this NetworkObject is included in the NetworkProjectConfig.PrefabTable, which will include the prefab in builds as a Spawnable object. More...
 
bool IsSpawnedPrefabNestedObject [get]
 Returns true if this network entity is a spawned prefab's nested object, rather than being a scene object or a root prefab object. More...
 
bool IsSpawnedPrefabRoot [get]
 Returns true if this network entity is a spawned prefab's root, rather than being a scene object or a nested prefab object. More...
 
bool IsValid [get]
 Returns if this network entity is associated with its NetworkRunner, and that runner is not null. More...
 
Tick LastReceiveTick [get]
 Last tick this object received an update. Only available for SimulationConfig.StateReplicationModes.EventualConsistency. More...
 
string Name [get]
 The ID + Unity GameObject name for this entity. More...
 
PlayerRef StateAuthority [get]
 Returns the PlayerRef that has State Authority over this network entity. PlayerRefs are assigned in order from 0 to MaxPlayers-1 and are re-used as players join and leave. The only caveat is that the server player (if one exists), always gets the last index no matter how many clients are connected. More...
 

Detailed Description

The primary Fusion component for networked GameObject entities. This stores the object's network identity and manages the object's state and input authority.

Member Function Documentation

◆ AssignInputAuthority()

void AssignInputAuthority ( PlayerRef  player)

Sets which PlayerRef has Input Authority for this Object.

◆ CopyStateFrom()

void CopyStateFrom ( NetworkObject  source)

Copies the entire State from another NetworkObject

Parameters
sourceNetworkObject to copy the State from

◆ CopyStateFromSceneObject()

void CopyStateFromSceneObject ( NetworkObjectHeaderPtr  source)

Copies the entire State from another Scene NetworkObject. They must have the same Scene Guid.

Parameters
sourceScene NetworkObject to copy the State from.

◆ GetLocalAuthorityMask()

int GetLocalAuthorityMask ( )

Gets a bitmask of AuthorityMasks flags, representing the current local authority over this NetworkObject.

◆ RemoveInputAuthority()

void RemoveInputAuthority ( )

Removes input authority from whichever player has it for this object. Only valid when called on a Host or Server peer.

◆ SetInterestGroup()

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

Add or remove Player's interest in a specific named Interest Group for this NetworkObject.

SimulationConfig.ReplicationMode must be set to SimulationConfig.StateReplicationModes.EventualConsistency.

◆ SetPlayerAlwaysInterested()

void SetPlayerAlwaysInterested ( PlayerRef  player,
bool  alwaysInterested 
)

Add or remove specific player interest in this NetworkObject.

SimulationConfig.ReplicationMode must be set to SimulationConfig.StateReplicationModes.EventualConsistency.

Parameters
player
alwaysInterested

Member Data Documentation

◆ Flags

NetworkObjectFlags Flags

Flags used for network object prefabs and similar

◆ Id

The unique identifier for this network entity.

◆ IsResume

bool IsResume

Signal that this NetworkObject comes from a Resume Spawn

◆ NestedObjects

NetworkObject [] NestedObjects

Array of initial child nested NetworkObject entities, that are children of this Object.

◆ NetworkedBehaviours

NetworkBehaviour [] NetworkedBehaviours

Array of all NetworkBehaviours associated with this network entity.

◆ NetworkGuid

NetworkObjectGuid NetworkGuid

The GUID for this prefab or scene object, which is set at development time. Used to reference this as a spawnable object. All spawned instances of this object will retain this GUID. Use NetworkId for the unique ID of network entries.

◆ PredictedSpawn

PredictionData PredictedSpawn

◆ Runner

NetworkRunner Runner

The NetworkRunner this entity is associated with.

◆ SimulationBehaviours

SimulationBehaviour [] SimulationBehaviours

Array of all SimulationBehaviours associated with this network entity. This does not include NetworkBehaviour derived classes, as they are stored in NetworkedBehaviours.

Property Documentation

◆ AreaOfInterestLayerMask

int AreaOfInterestLayerMask
get

The layers this object exists in for area of interest queries. This is an integer bitmask not a layer index.

◆ HasInputAuthority

bool HasInputAuthority
get

Returns if Simulation.LocalPlayer is the designated Input Authority for this network entity.

◆ HasStateAuthority

bool HasStateAuthority
get

Returns if Simulation.LocalPlayer is the designated State Authority for this network entity.

◆ InputAuthority

PlayerRef InputAuthority
get

Returns the PlayerRef that has Input Authority over this network entity. 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.

◆ IsInSimulation

bool IsInSimulation
get

If this object is inserted into the simulation

◆ IsPredictedDespawn

bool IsPredictedDespawn
get

If this is a predicted spawned object

◆ IsPredictedSpawn

bool IsPredictedSpawn
get

If this is a predicted spawned object

◆ IsProxy

bool IsProxy
get

Returns if Simulation.LocalPlayer is neither the Input nor State Authority for this network entity.

◆ IsSceneObject

bool IsSceneObject
get

Returns true if this network entity existed as part of a scene, rather than having been dynamically spawned.

◆ IsSpawnable

bool IsSpawnable
getset

Toggles if this NetworkObject is included in the NetworkProjectConfig.PrefabTable, which will include the prefab in builds as a Spawnable object.

◆ IsSpawnedPrefabNestedObject

bool IsSpawnedPrefabNestedObject
get

Returns true if this network entity is a spawned prefab's nested object, rather than being a scene object or a root prefab object.

◆ IsSpawnedPrefabRoot

bool IsSpawnedPrefabRoot
get

Returns true if this network entity is a spawned prefab's root, rather than being a scene object or a nested prefab object.

◆ IsValid

bool IsValid
get

Returns if this network entity is associated with its NetworkRunner, and that runner is not null.

◆ LastReceiveTick

Tick LastReceiveTick
get

Last tick this object received an update. Only available for SimulationConfig.StateReplicationModes.EventualConsistency.

◆ Name

string Name
get

The ID + Unity GameObject name for this entity.

◆ StateAuthority

PlayerRef StateAuthority
get

Returns the PlayerRef that has State Authority over this network entity. 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.