Photon Fusion 1.1.9

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.
 
void CopyStateFrom (NetworkObject source)
 Copies the entire State from another NetworkObject
 
void CopyStateFromSceneObject (NetworkObjectHeaderPtr source)
 Copies the entire State from another Scene NetworkObject. They must have the same Scene Guid.
 
int GetLocalAuthorityMask ()
 Gets a bitmask of AuthorityMasks flags, representing the current local authority over this NetworkObject.
 
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.
 
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.
 
void SetPlayerAlwaysInterested (PlayerRef player, bool alwaysInterested)
 Add or remove specific player interest in this NetworkObject.
 
- 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 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()
 

Public Attributes

NetworkObjectFlags Flags
 Flags used for network object prefabs and similar.
 
NetworkId Id
 The unique identifier for this network entity.
 
bool IsResume
 Signal that this NetworkObject comes from a Resume Spawn.
 
NetworkObject[] NestedObjects
 Array of initial child nested NetworkObject entities, that are children of this Object.
 
NetworkBehaviour[] NetworkedBehaviours
 Array of all NetworkBehaviours associated with this network entity.
 
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.
 
PredictionData PredictedSpawn
 
NetworkRunner Runner
 The NetworkRunner this entity is associated with.
 
SimulationBehaviour[] SimulationBehaviours
 Array of all SimulationBehaviours associated with this network entity. This does not include NetworkBehaviour derived classes, as they are stored in NetworkedBehaviours.
 

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.
 
bool HasInputAuthority [get]
 Returns if Simulation.LocalPlayer is the designated Input Authority for this network entity.
 
bool HasStateAuthority [get]
 Returns if Simulation.LocalPlayer is the designated State Authority for this network entity.
 
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.
 
bool IsInSimulation [get]
 If this object is inserted into the simulation.
 
bool IsPredictedDespawn [get]
 If this is a predicted spawned object.
 
bool IsPredictedSpawn [get]
 If this is a predicted spawned object.
 
bool IsProxy [get]
 Returns if Simulation.LocalPlayer is neither the Input nor State Authority for this network entity.
 
bool IsSceneObject [get]
 Returns true if this network entity existed as part of a scene, rather than having been dynamically spawned.
 
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.
 
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.
 
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.
 
bool IsValid [get]
 Returns if this network entity is associated with its NetworkRunner, and that runner is not null.
 
Tick LastReceiveTick [get]
 Last tick this object received an update. Only available for SimulationConfig.StateReplicationModes.EventualConsistency.
 
string Name [get]
 The ID + Unity GameObject name for this entity.
 
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.
 

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

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

◆ 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