Photon Fusion 1.1.2

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

int GetLocalAuthorityMask ()
 Gets a bitmask of AuthorityMasks flags, representing the current local authority over this NetworkObject. More...
 
void AssignInputAuthority (PlayerRef player)
 Sets which PlayerRef has Input Authority for this Object. More...
 
void RequestStateAuthority ()
 
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 SetPlayerAlwaysInterested (PlayerRef player, bool alwaysInterested)
 Add or remove specific player interest in this NetworkObject. More...
 
void CopyStateFrom (NetworkObject networkObject)
 Copies the entire State from another NetworkObject More...
 
void CopyStateFromSceneObject (NetworkObjectHeaderPtr networkObject)
 Copies the entire State from another Scene Object. They must have the same Scene Guid More...
 
void SetInterestGroup (PlayerRef player, string group, bool interested)
 Add or remove Player's interest in a specific named Interest Group for this NetworkObject. More...
 
- Public Member Functions inherited from Behaviour
AddBehaviour< T > ()
 Wrapper for Unity's GameObject.AddComponent() More...
 
bool TryGetBehaviour< T > (out T behaviour)
 Wrapper for Unity's GameObject.TryGetComponent() More...
 
GetBehaviour< T > ()
 Wrapper for Unity's GameObject.GetComponentInChildren() More...
 

Static Public Member Functions

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

Public Attributes

NetworkId Id
 The unique identifier for this network entity. More...
 
bool IsResume
 Signal that this NetworkObject comes from a Resume Spawn More...
 
NetworkRunner Runner
 The NetworkRunner this entity is associated with. More...
 
NetworkObjectFlags Flags
 Flags used for network object prefabs and similar 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
 
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...
 
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

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...
 
bool IsSceneObject [get]
 Returns if this network entity existed as part of a scene, rather than having been dynamically spawned. More...
 
bool IsValid [get]
 Returns if this network entity is associated with its NetworkRunner, and that runner is not null. More...
 
bool IsPredictedSpawn [get]
 If this is a predicted spawned object More...
 
bool IsPredictedDespawn [get]
 If this is a predicted spawned object More...
 
bool IsInSimulation [get]
 If this object is inserted into the simulation 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...
 
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...
 
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...
 
bool IsProxy [get]
 Returns if Simulation.LocalPlayer is neither the Input nor State Authority for this network entity. 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...
 

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  networkObject)

Copies the entire State from another NetworkObject

Parameters
networkObjectNetworkObject to copy the State from

◆ CopyStateFromSceneObject()

void CopyStateFromSceneObject ( NetworkObjectHeaderPtr  networkObject)

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

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

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