Table of Contents

Class NetworkObject

Namespace
Netick.Unity
Assembly
Netick.Unity.dll

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

int

BroadPhaseFilter

public BroadPhaseFilter BroadPhaseFilter { get; }

Property Value

BroadPhaseFilter

Engine

The NetickEngine this NetworkObject belongs to.

public NetickEngine Engine { get; }

Property Value

NetickEngine

Entity

The Entity this NetworkObject represents in the Netick simulation.

public Entity Entity { get; }

Property Value

Entity

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

bool

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

int

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

NetworkPlayer

InputSourcePlayerId

Returns the NetworkPlayerId of the input source of this object. This is synced to every client.

public NetworkPlayerId InputSourcePlayerId { get; }

Property Value

NetworkPlayerId

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

InterestManagementGroup

IsClient

Returns true if this NetworkSandbox is a client.

public bool IsClient { get; }

Property Value

bool

IsInputSource

Returns true if this LocalPlayer is providing inputs for this NetworkObject.

public bool IsInputSource { get; }

Property Value

bool

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

bool

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

bool

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

bool

IsPersistent

public bool IsPersistent { get; }

Property Value

bool

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

bool

IsProxy

Returns true if we neither provide inputs nor own this object.

public bool IsProxy { get; }

Property Value

bool

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

bool

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

bool

IsServer

Returns true if this NetworkSandbox is the server.

public bool IsServer { get; }

Property Value

bool

NarrowPhaseFilter

public bool NarrowPhaseFilter { get; }

Property Value

bool

NetickBehaviours

Returns the NetickBehaviour components attached to this NetworkObject.

public NetickBehaviour[] NetickBehaviours { get; }

Property Value

NetickBehaviour[]

NetworkedBehaviours

Returns the NetworkBehaviour components attached to this NetworkObject.

public NetworkBehaviour[] NetworkedBehaviours { get; }

Property Value

NetworkBehaviour[]

Parent

The NetworkObject parent of this object.

public NetworkObject Parent { get; }

Property Value

NetworkObject

PredictionMode

public Relevancy PredictionMode { get; }

Property Value

Relevancy

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

int

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

int

Sandbox

The NetworkSandbox this NetworkObject belongs to.

public NetworkSandbox Sandbox { get; }

Property Value

NetworkSandbox

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

int

SpatialPrioritization

public bool SpatialPrioritization { get; }

Property Value

bool

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

Tick

StateSize

Returns the networked state size of this object in bytes.

public int StateSize { get; }

Property Value

int

Methods

ClearState(bool)

Zeros out the networked state memory of this object. Ignores InputSource Relevancy.

public void ClearState(bool invokeOnChanged = true)

Parameters

invokeOnChanged bool

CopyStateTo(byte*)

Copies the state of this object into target.

public void CopyStateTo(byte* target)

Parameters

target byte*

CopyStateTo(byte[])

Copies the state of this object into target.

public void CopyStateTo(byte[] target)

Parameters

target byte[]

GetBehaviourById<T>(int)

public T GetBehaviourById<T>(int id) where T : NetworkBehaviour

Parameters

id int

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

NetworkObjectRef

GetSceneId()

[Obsolete("Use SceneId instead. This will be removed in the future.")]
public int GetSceneId()

Returns

int

GetStateRef()

public EntityStateRef GetStateRef()

Returns

EntityStateRef

SetInitialProperties(bool, Relevancy, bool, BroadPhaseFilter, bool)

public void SetInitialProperties(bool isPersistent, Relevancy predictionMode, bool addToNetworkLoop, BroadPhaseFilter broadPhaseFilter, bool narrowPhaseFilter)

Parameters

isPersistent bool
predictionMode Relevancy
addToNetworkLoop bool
broadPhaseFilter BroadPhaseFilter
narrowPhaseFilter bool

SetNarrowphaseInterest(NetworkPlayer, bool)

public void SetNarrowphaseInterest(NetworkPlayer player, bool isInterested)

Parameters

player NetworkPlayer
isInterested bool

SetNarrowphaseInterest(NetworkPlayerId, bool)

public void SetNarrowphaseInterest(NetworkPlayerId player, bool isInterested)

Parameters

player NetworkPlayerId
isInterested bool

SetParent(NetworkObject)

[Owner/InputSource Only] Changes the parent of this object.

public void SetParent(NetworkObject obj)

Parameters

obj NetworkObject

The object which will become the parent of this object.

SetStateFrom(EntityStateRef, byte*, bool)

public void SetStateFrom(EntityStateRef stateRef, byte* worldSnapshot, bool invokeOnChanged = true)

Parameters

stateRef EntityStateRef
worldSnapshot byte*
invokeOnChanged bool

SetStateFrom(EntityStateRef, byte[], bool)

public virtual void SetStateFrom(EntityStateRef stateRef, byte[] worldSnapshot, bool invokeOnChanged = true)

Parameters

stateRef EntityStateRef
worldSnapshot byte[]
invokeOnChanged bool

SetStateFrom(byte*, bool)

Sets the state of this object. Ignores InputSource Relevancy.

public void SetStateFrom(byte* source, bool invokeOnChanged = true)

Parameters

source byte*
invokeOnChanged bool

SetStateFrom(byte[], bool)

Sets the state of this object. Ignores InputSource Relevancy.

public void SetStateFrom(byte[] source, bool invokeOnChanged = true)

Parameters

source byte[]
invokeOnChanged bool

UpdateAoI()

public void UpdateAoI()

UpdateAoI(Vector3)

public void UpdateAoI(Vector3 position)

Parameters

position Vector3