Class NetworkObject
Any GameObject which needs to be synced/replicated must have a Network Object component. It’s the component that tells Netick a GameObject is networked. Although not every child GameObject needs it, only the root has to have a Network Object.
public class NetworkObject : MonoBehaviour, INetickEntity
- Inheritance
-
NetworkObject
- Implements
Constructors
NetworkObject()
public NetworkObject()
Properties
AoILayer
public int AoILayer { get; }
Property Value
BroadPhaseFilter
public BroadPhaseFilter BroadPhaseFilter { get; }
Property Value
Engine
The NetickEngine this NetworkObject belongs to.
public NetickEngine Engine { get; }
Property Value
Entity
The Entity this NetworkObject represents in the Netick simulation.
public Entity Entity { get; }
Property Value
HasValidId
Returns true if this NetworkObject has been added to the simulation by Netick, and thus has a valid id.
public bool HasValidId { get; }
Property Value
Id
Returns the unique identifier of this NetworkObject in the Netick simulation. This id is assigned by the Netick when the object is added to the simulation and is used to identify the object across the network.
public int Id { get; }
Property Value
InputSource
Returns the source NetworkPlayer (NetworkPeer/ServerConnection) of inputs for this NetworkObject. If the source of inputs is remote (from a client) it returns that ServerConnection, while on the input source itself it returns the local NetworkPlayer.
Use InputSourcePlayerId for the synced-to-everyone player id of the Input Source - because InputSource is only valid in the client for objects the client itself is the input source of, and it's null for everything else.
public NetworkPlayer InputSource { get; set; }
Property Value
InputSourcePlayerId
Returns the NetworkPlayerId of the input source of this object. This is synced to every client.
public NetworkPlayerId InputSourcePlayerId { get; }
Property Value
InterestGroup
The interest group of this object. This can only be changed if BroadPhaseFilter is set to Custom.
public InterestManagementGroup InterestGroup { get; set; }
Property Value
IsClient
Returns true if this NetworkSandbox is a client.
public bool IsClient { get; }
Property Value
IsInputSource
Returns true if this LocalPlayer is providing inputs for this NetworkObject.
public bool IsInputSource { get; }
Property Value
IsInterested
[Client Only] On the client, returns true if this client is interested in this object. On the server, always returns true.
public bool IsInterested { get; }
Property Value
IsMarkedForDestruction
[Server Only] Returns true if Destroy(NetworkObject) has been called on this object in the server, and the object is scheduled to be removed from the simulation (destroyed) at the end of the current tick.
public bool IsMarkedForDestruction { get; }
Property Value
IsOwner
Returns true if this NetworkSandbox is the owner of this Object. In this version of Netick: Server=Owner.
public bool IsOwner { get; }
Property Value
IsPersistent
public bool IsPersistent { get; }
Property Value
IsPrefabObject
Returns true if this NetworkObject is a prefab object (not a scene object). Prefab objects are objects that are instantiated from a prefab and not part of the scene.
public bool IsPrefabObject { get; }
Property Value
IsProxy
Returns true if we neither provide inputs nor own this object.
public bool IsProxy { get; }
Property Value
IsResimulating
Returns true if we are currently resimulating a previous input of the past. On the server, it always returns false since only the clients resimulate.
public bool IsResimulating { get; }
Property Value
IsSceneObject
Returns true if this NetworkObject is a scene object (not a prefab instance). Scene objects are objects that are part of the scene and not instantiated from a prefab.
public bool IsSceneObject { get; }
Property Value
IsServer
Returns true if this NetworkSandbox is the server.
public bool IsServer { get; }
Property Value
NarrowPhaseFilter
public bool NarrowPhaseFilter { get; }
Property Value
NetickBehaviours
Returns the NetickBehaviour components attached to this NetworkObject.
public NetickBehaviour[] NetickBehaviours { get; }
Property Value
NetworkedBehaviours
Returns the NetworkBehaviour components attached to this NetworkObject.
public NetworkBehaviour[] NetworkedBehaviours { get; }
Property Value
Parent
The NetworkObject parent of this object.
public NetworkObject Parent { get; }
Property Value
PredictionMode
public Relevancy PredictionMode { get; }
Property Value
PrefabId
Returns the prefab id of this NetworkObject. This is used to identify the prefab from which this object was instantiated. If this object is a scene object, it returns -1.
public int PrefabId { get; }
Property Value
RuntimeSceneId
Returns the runtime scene id of this NetworkObject. This value is only unique per-scene, and not per the entire game.
public int RuntimeSceneId { get; }
Property Value
Sandbox
The NetworkSandbox this NetworkObject belongs to.
public NetworkSandbox Sandbox { get; }
Property Value
SceneId
Returns the scene id of this NetworkObject. This value is only unique per-scene, and not per the entire game.
public int SceneId { get; }
Property Value
SpatialPrioritization
public bool SpatialPrioritization { get; }
Property Value
SpawnTick
Returns the tick at which this NetworkObject was spawned locally. This is a local value, and is not synced.
public Tick SpawnTick { get; }
Property Value
StateSize
Returns the networked state size of this object in bytes.
public int StateSize { get; }
Property Value
Methods
ClearState(bool)
Zeros out the networked state memory of this object. Ignores InputSource Relevancy.
public void ClearState(bool invokeOnChanged = true)
Parameters
invokeOnChangedbool
CopyStateTo(byte*)
Copies the state of this object into target.
public void CopyStateTo(byte* target)
Parameters
targetbyte*
CopyStateTo(byte[])
Copies the state of this object into target.
public void CopyStateTo(byte[] target)
Parameters
targetbyte[]
GetBehaviourById<T>(int)
public T GetBehaviourById<T>(int id) where T : NetworkBehaviour
Parameters
idint
Returns
- T
Type Parameters
T
GetBehaviour<T>()
public T GetBehaviour<T>() where T : NetworkBehaviour
Returns
- T
Type Parameters
T
GetRef()
Returns a network-serializable reference to this NetworkObject. This is used to get a networkable identifier for this object, which can be used for RPCs or network properties.
public NetworkObjectRef GetRef()
Returns
GetSceneId()
[Obsolete("Use SceneId instead. This will be removed in the future.")]
public int GetSceneId()
Returns
GetStateRef()
public EntityStateRef GetStateRef()
Returns
SetInitialProperties(bool, Relevancy, bool, BroadPhaseFilter, bool)
public void SetInitialProperties(bool isPersistent, Relevancy predictionMode, bool addToNetworkLoop, BroadPhaseFilter broadPhaseFilter, bool narrowPhaseFilter)
Parameters
isPersistentboolpredictionModeRelevancyaddToNetworkLoopboolbroadPhaseFilterBroadPhaseFilternarrowPhaseFilterbool
SetNarrowphaseInterest(NetworkPlayer, bool)
public void SetNarrowphaseInterest(NetworkPlayer player, bool isInterested)
Parameters
playerNetworkPlayerisInterestedbool
SetNarrowphaseInterest(NetworkPlayerId, bool)
public void SetNarrowphaseInterest(NetworkPlayerId player, bool isInterested)
Parameters
playerNetworkPlayerIdisInterestedbool
SetParent(NetworkObject)
[Owner/InputSource Only] Changes the parent of this object.
public void SetParent(NetworkObject obj)
Parameters
objNetworkObjectThe object which will become the parent of this object.
SetStateFrom(EntityStateRef, byte*, bool)
public void SetStateFrom(EntityStateRef stateRef, byte* worldSnapshot, bool invokeOnChanged = true)
Parameters
stateRefEntityStateRefworldSnapshotbyte*invokeOnChangedbool
SetStateFrom(EntityStateRef, byte[], bool)
public virtual void SetStateFrom(EntityStateRef stateRef, byte[] worldSnapshot, bool invokeOnChanged = true)
Parameters
stateRefEntityStateRefworldSnapshotbyte[]invokeOnChangedbool
SetStateFrom(byte*, bool)
Sets the state of this object. Ignores InputSource Relevancy.
public void SetStateFrom(byte* source, bool invokeOnChanged = true)
Parameters
SetStateFrom(byte[], bool)
Sets the state of this object. Ignores InputSource Relevancy.
public void SetStateFrom(byte[] source, bool invokeOnChanged = true)
Parameters
UpdateAoI()
public void UpdateAoI()
UpdateAoI(Vector3)
public void UpdateAoI(Vector3 position)
Parameters
positionVector3