Table of Contents

Class NetworkSandbox

Namespace
Netick.Unity
Assembly
Netick.Unity.dll

NetworkSandbox represents a networked game instance in Netick.

public class NetworkSandbox : MonoBehaviour, IGameEngine
Inheritance
NetworkSandbox
Implements

Constructors

NetworkSandbox()

public NetworkSandbox()

Properties

AuthoritativeTick

Last received tick on the client. On the server, it returns the same value as Sandbox.Tick.

public Tick AuthoritativeTick { get; }

Property Value

Tick

Config

Configuration data for Netick.

public NetickConfig Config { get; }

Property Value

NetickConfig

ConnectedClients

A list containing all connected clients currently.

Note: if you want the clients + the server, use ConnectedPlayers.

[Obsolete("This will be removed in the future, please use Players instead.")]
public IReadOnlyList<ServerConnection> ConnectedClients { get; }

Property Value

IReadOnlyList<ServerConnection>

ConnectedPlayers

A list containing all connected clients currently, in addition to the server (when started as a host).

Note: if you only want the clients, use ConnectedClients.

[Obsolete("This will be removed in the future, please use Players instead.")]
public IReadOnlyList<NetworkPlayer> ConnectedPlayers { get; }

Property Value

IReadOnlyList<NetworkPlayer>

ConnectedServer

The server the client is connected to.

public NetworkConnection ConnectedServer { get; }

Property Value

NetworkConnection

CurrentRpcCaller

Always always returns null except when called inside the body of an RPC method, it returns the NetworkPlayer we are executing RPCs from. Works the same as CurrentRpcSource, except when the RPC is called by the local player, it returns Sandbox.LocalPlayer.

[Obsolete("This will be removed in the future, please read the doc article on Rpcs to learn the new replacement.")]
public NetworkPlayer CurrentRpcCaller { get; }

Property Value

NetworkPlayer

CurrentRpcSource

Always always returns null except when called inside the body of an RPC method, it returns the NetworkConnection we are executing RPCs from.

[Obsolete("This will be removed in the future, please read the doc article on Rpcs to learn the new replacement.")]
public NetworkConnection CurrentRpcSource { get; }

Property Value

NetworkConnection

DeltaTime

Time period between frames. Same as UnityEngine.Time.deltaTime

public float DeltaTime { get; }

Property Value

float

Engine

The NetickEngine instance attached to this sandbox.

public NetickEngine Engine { get; }

Property Value

NetickEngine

Events

Use this to subscribe/unsubscribe to/from Netick events.

public NetworkCallbacks Events { get; }

Property Value

NetworkCallbacks

FixedDeltaTime

Time period between network simulation steps. Same as UnityEngine.Time.fixedDeltaTime

public float FixedDeltaTime { get; }

Property Value

float

InKBps

Average incoming data in kilobytes per second (KBps).

public float InKBps { get; }

Property Value

float

InPacketLoss

[Client Only] Estimation of incoming packets that are being lost. Value ranges between 0.0 and 1.0, with 1.0 meaning all packets are being lost.

public float InPacketLoss { get; }

Property Value

float

InputEnabled

Returns true if input is enabled on this sandbox. Use this to enable/disable input at runtime.

public bool InputEnabled { get; set; }

Property Value

bool

InterestManagement

Use this to manage interest groups and area of interest (AoI) layers.

public InterestManagement InterestManagement { get; }

Property Value

InterestManagement

InterpolationDelay

[Client Only] Remote Interpolation delay in seconds.

public float InterpolationDelay { get; }

Property Value

float

IsClient

Returns true if this NetworkSandbox is a client.

public bool IsClient { get; }

Property Value

bool

IsConnected

[Client Only] Returns true if this client is currently connected to a server.

public bool IsConnected { get; }

Property Value

bool

IsFirstNetworkFixedUpdateCall

Returns true if this NetworkFixedUpdate call is the first one executed in this frame. This excludes re-simulations, and it only refers to new/forward ticks.

public bool IsFirstNetworkFixedUpdateCall { get; }

Property Value

bool

IsHost

Returns true if this NetworkSandbox is a host.

public bool IsHost { get; }

Property Value

bool

IsLastNetworkFixedUpdateCall

Returns true if this NetworkFixedUpdate call is the last one executed in this frame. This excludes re-simulations, and it only refers to new/forward ticks.

public bool IsLastNetworkFixedUpdateCall { get; }

Property Value

bool

IsPlayer

Returns true if this NetworkSandbox is a player, which is the case when running as a Client, Host, or in Single-Player mode.

public bool IsPlayer { get; }

Property Value

bool

IsRecording

Returns true if Netick is recording for replay.

public bool IsRecording { get; }

Property Value

bool

IsReplay

Returns true if Netick is running in ReplayClient mode.

public bool IsReplay { get; }

Property Value

bool

IsResimulating

Returns true if we are currently re-simulating a previous input/tick of the past. On the server, it always returns false since only the clients resimulate.

public bool IsResimulating { get; }

Property Value

bool

IsRunning

Returns true if this NetworkSandbox has been started.

public bool IsRunning { get; }

Property Value

bool

IsServer

Returns true if this NetworkSandbox is the server.

public bool IsServer { get; }

Property Value

bool

IsVisible

Returns true if this sandbox is visible. Use this to enable/disable visibility at runtime.

public bool IsVisible { get; set; }

Property Value

bool

LocalAlpha

Returns the progress of this sandbox between the current and next tick. A value of 0 represents the start of the current tick, and 1 represents the end of the tick (start of the next tick). Same as Alpha.

public float LocalAlpha { get; }

Property Value

float

LocalInterpolation

The Local (predicted) Interpolation instance used for interpolating local/predicted objects. Includes useful interpolation data, such as the current interpolation alpha, the ticks being interpolated, and the local interpolation time (in seconds).

public LocalInterpolation LocalInterpolation { get; }

Property Value

LocalInterpolation

LocalPlayer

The local player of this sandbox instance.

public NetworkPlayer LocalPlayer { get; }

Property Value

NetworkPlayer

Monitor

Used to track network metrics and statistics.

public Monitor Monitor { get; }

Property Value

Monitor

Name

Name of this sandbox.

public string Name { get; }

Property Value

string

NetworkTime

Current (local/predicted) network time in seconds. Same as Time.

public float NetworkTime { get; }

Property Value

float

Objects

A dictionary containing all simulated/registered network objects [NetworkObject] currently.

public IReadOnlyDictionary<int, NetworkObject> Objects { get; }

Property Value

IReadOnlyDictionary<int, NetworkObject>

OutKBps

Average outgoing data in kilobytes per second (KBps).

public float OutKBps { get; }

Property Value

float

OutPacketLoss

[Client Only] Estimation of outgoing packets that are being lost. Value ranges between 0.0 and 1.0, with 1.0 meaning all packets are being lost.

public float OutPacketLoss { get; }

Property Value

float

Physics

The UnityEngine.PhysicsScene associated with this NetworkSandbox. Always use this to perform physics queries inside the sandbox instead of UnityEngine.Physics.

public PhysicsScene Physics { get; }

Property Value

PhysicsScene

Physics2D

The UnityEngine.PhysicsScene2D associated with this NetworkSandbox. Always use this to perform physics queries inside the sandbox instead of UnityEngine.Physics2D.

public PhysicsScene2D Physics2D { get; }

Property Value

PhysicsScene2D

PhysicsPrediction

Use this to enable/disable Physics Prediction in the client at runtime.

public bool PhysicsPrediction { get; set; }

Property Value

bool

Players

A list containing the ids of all connected players currently. This list is networked and synced to all clients.

public IReadOnlyList<NetworkPlayerId> Players { get; }

Property Value

IReadOnlyList<NetworkPlayerId>

PredictedTick

Last predicted tick.

On the client, it always returns the predicted tick of the client, regardless of whether it's a resimulation or not.

On the server, it returns the same value as Sandbox.Tick

public Tick PredictedTick { get; }

Property Value

Tick

RTT

[Client Only] The round-trip time (RTT) of the client in seconds.

public double RTT { get; }

Property Value

double

RemoteInterpolation

The Remote Interpolation instance used for interpolating remote objects on the client. Includes useful interpolation data, such as the current interpolation alpha, the ticks being interpolated, the remote interpolation time (in seconds), and the remote interpolation delay (in seconds).

Note: this is only valid in the client.

public RemoteInterpolation RemoteInterpolation { get; }

Property Value

RemoteInterpolation

Replay

Use this to manage the replay system. Returns null when replay is not enabled.

public Replay Replay { get; }

Property Value

Replay

ReplayTransport

The underlying transport used for replay.

public IReplayTransport ReplayTransport { get; }

Property Value

IReplayTransport

ResimulationCount

[Client Only] The number of re-simulations that have been performed in this tick. This is only valid on the client (and during the re-simulation stage), and it returns 0 on the server.

public int ResimulationCount { get; }

Property Value

int

ResimulationStep

[Client Only] Returns the current re-simulation step we are currently performing, if we are in the re-simulation stage. This is only valid on the client, and it returns 0 on the server.

public int ResimulationStep { get; }

Property Value

int

Resimulations

[Obsolete("This will be removed in the future, please use ResimulationCount instead.")]
public int Resimulations { get; }

Property Value

int

ScaledFixedDeltaTime

Scaled time period between network simulation steps. This is the same as UnityEngine.Time.fixedDeltaTime, but multiplied by UnityEngine.Time.timeScale.

public float ScaledFixedDeltaTime { get; }

Property Value

float

Scene

The UnityEngine.SceneManagement.Scene associated with this NetworkSandbox.

public Scene Scene { get; }

Property Value

Scene

ServerEndPoint

[Client Only] The IEndPoint of the server you are connected to. Returns null if you are not connected to any server, or if you are the server.

public IEndPoint ServerEndPoint { get; }

Property Value

IEndPoint

StartMode

The mode this sandbox was started in.

public NetickStartMode StartMode { get; }

Property Value

NetickStartMode

Tick

Current simulation tick.

On the server, it's always going forward/increasing.

On the client, during resimulations it returns the current re-simulated tick. To check for resimulations, use IsResimulating.

public Tick Tick { get; }

Property Value

Tick

Timer

The simulation clock used for managing time in the network simulation.

public SimulationClock Timer { get; }

Property Value

SimulationClock

Transport

The underlying transport used for low-level networking.

public NetworkTransport Transport { get; }

Property Value

NetworkTransport

UserObject

Use this to associate an object with this sandbox.

public object UserObject { get; set; }

Property Value

object

Methods

AttachBehaviour(NetickBehaviour)

Attaches a NetickBehaviour to the simulation.

public void AttachBehaviour(NetickBehaviour behaviour)

Parameters

behaviour NetickBehaviour

AttachGameObject(GameObject)

public void AttachGameObject(GameObject gameObject)

Parameters

gameObject GameObject

AttachNonNetworkedRigidbody(GameObject)

public void AttachNonNetworkedRigidbody(GameObject rigidbodyGameObject)

Parameters

rigidbodyGameObject GameObject

AttachNonNetworkedRigidbody(Rigidbody)

public void AttachNonNetworkedRigidbody(Rigidbody rigidbody)

Parameters

rigidbody Rigidbody

Connect(int, string)

[Client Only] Connects to a remote server.

Note: if you are already connected to a server, and you want to connect to a different one, you have to disconnect before calling this. Otherwise this method does nothing.

Note: connectionData array length should not be more than 300 if you are using Netick Transport.

public void Connect(int port, string ip)

Parameters

port int

Port of the server.

ip string

IP address of the server.

Connect(int, string, ArraySegment<byte>)

public void Connect(int port, string ip, ArraySegment<byte> data)

Parameters

port int
ip string
data ArraySegment<byte>

Connect(int, string, byte[], int)

public void Connect(int port, string ip, byte[] connectionData, int connectionDataLength)

Parameters

port int
ip string
connectionData byte[]
connectionDataLength int

ContainsPlayer(NetworkPlayerId)

Checks if a player with the specified NetworkPlayerId exists in the simulation.

public bool ContainsPlayer(NetworkPlayerId playerId)

Parameters

playerId NetworkPlayerId

Returns

bool

CreateMatch(string)

[Server Only] Creates a match. Only functional if the low-level transport has support for matchmaking.

public void CreateMatch(string name)

Parameters

name string

Name of the match.

Destroy(NetworkObject)

[Server Only] Destroys a network object.

Note: never call this on a child NetworkObject of the original prefab, only the root of the prefab.

public void Destroy(NetworkObject obj)

Parameters

obj NetworkObject

The object to destroy.

DestroyPool(NetworkObject)

public void DestroyPool(NetworkObject networkedPrefab)

Parameters

networkedPrefab NetworkObject

DestroyPool(GameObject)

public void DestroyPool(GameObject networkedPrefab)

Parameters

networkedPrefab GameObject

DetachBehaviour(NetickBehaviour)

Detaches a NetickBehaviour from the simulation.

public void DetachBehaviour(NetickBehaviour behaviour)

Parameters

behaviour NetickBehaviour

DetachGameObject(GameObject)

public void DetachGameObject(GameObject gameObject)

Parameters

gameObject GameObject

DetachNonNetworkedRigidbody(GameObject)

public void DetachNonNetworkedRigidbody(GameObject rigidbodyGameObject)

Parameters

rigidbodyGameObject GameObject

DetachNonNetworkedRigidbody(Rigidbody)

public void DetachNonNetworkedRigidbody(Rigidbody rigidbody)

Parameters

rigidbody Rigidbody

DisableComponent(Component)

public void DisableComponent(Component component)

Parameters

component Component

DisconnectFromServer()

[Client Only] Disconnects this client from the server.

public void DisconnectFromServer()

EnableComponent(Component)

public void EnableComponent(Component component)

Parameters

component Component

FindGameObjectWithTag(string, bool)

public GameObject FindGameObjectWithTag(string tag, bool activeOnly = true)

Parameters

tag string
activeOnly bool

Returns

GameObject

FindGameObjectsWithTag(string, bool)

public List<GameObject> FindGameObjectsWithTag(string tag, bool activeOnly = true)

Parameters

tag string
activeOnly bool

Returns

List<GameObject>

FindGameObjectsWithTag(string, List<GameObject>, bool)

public List<GameObject> FindGameObjectsWithTag(string tag, List<GameObject> results, bool activeOnly = true)

Parameters

tag string
results List<GameObject>
activeOnly bool

Returns

List<GameObject>

FindObjectOfType<T>(bool)

public T FindObjectOfType<T>(bool activeOnly = true) where T : class

Parameters

activeOnly bool

Returns

T

Type Parameters

T

FindObjectsOfType<T>(bool)

public List<T> FindObjectsOfType<T>(bool activeOnly = true) where T : class

Parameters

activeOnly bool

Returns

List<T>

Type Parameters

T

FindObjectsOfType<T>(List<T>, bool)

public void FindObjectsOfType<T>(List<T> results, bool activeOnly = true) where T : class

Parameters

results List<T>
activeOnly bool

Type Parameters

T

FindPlayerByEndPoint(IEndPoint)

public NetworkPlayer FindPlayerByEndPoint(IEndPoint endPoint)

Parameters

endPoint IEndPoint

Returns

NetworkPlayer

FindSandboxOf(GameObject)

Finds the NetworkSandbox instance associated with the specified UnityEngine.GameObject. Returns null if networking is not running or if no matching sandbox is found for the object's scene.

public static NetworkSandbox FindSandboxOf(GameObject go)

Parameters

go GameObject

The UnityEngine.GameObject to find the sandbox for.

Returns

NetworkSandbox

The NetworkSandbox associated with the object's scene, or null if not found.

FindSandboxOf(MonoBehaviour)

Finds the NetworkSandbox instance associated with the specified UnityEngine.GameObject. Returns null if networking is not running or if no matching sandbox is found for the object's scene.

public static NetworkSandbox FindSandboxOf(MonoBehaviour monoBehaviour)

Parameters

monoBehaviour MonoBehaviour

Returns

NetworkSandbox

The NetworkSandbox associated with the object's scene, or null if not found.

GetBehaviour<T>(NetworkBehaviourRef<T>)

public T GetBehaviour<T>(NetworkBehaviourRef<T> networkBehaviourRef) where T : NetworkBehaviour

Parameters

networkBehaviourRef NetworkBehaviourRef<T>

Returns

T

Type Parameters

T

GetBehavioursOfType<T>()

Gets all network behaviours (or Netick behaviours) in the simulation that have the type of T.

public List<T> GetBehavioursOfType<T>() where T : NetickBehaviour

Returns

List<T>

Type Parameters

T

GetBehavioursOfType<T>(List<T>)

Gets all network behaviours (or Netick behaviours) in the simulation that have the type of T.

public void GetBehavioursOfType<T>(List<T> result) where T : NetickBehaviour

Parameters

result List<T>

Type Parameters

T

GetDefaultLoadSceneParameters()

public LoadSceneParameters GetDefaultLoadSceneParameters()

Returns

LoadSceneParameters

GetDefaultPhysicsMode()

public LocalPhysicsMode GetDefaultPhysicsMode()

Returns

LocalPhysicsMode

GetInput<T>(int)

Gets a specific input for the next tick.

public T GetInput<T>(int index = 0) where T : unmanaged

Parameters

index int

Returns

T

Type Parameters

T

GetLocalPlayerObject()

Gets the the associated NetworkObject (player object) with the local player.

public NetworkObject GetLocalPlayerObject()

Returns

NetworkObject

GetLocalPlayerObject<T>()

Gets the the associated script (player object) of type T with the local player.

public T GetLocalPlayerObject<T>() where T : NetickBehaviour

Returns

T

Type Parameters

T

GetObject(NetworkObjectRef)

public NetworkObject GetObject(NetworkObjectRef networkObjectRef)

Parameters

networkObjectRef NetworkObjectRef

Returns

NetworkObject

GetObject(int)

Gets the NetworkObject with the specified id. Returns null in case no object with that id exists.

public NetworkObject GetObject(int id)

Parameters

id int

The id of the NetworkObject

Returns

NetworkObject

GetPlayerById(NetworkPlayerId)

Retrieves the NetworkPlayer associated with the given NetworkPlayerId.

On the server, this method can return any player by their ID. On the client, it only returns the local player or the server player.

public NetworkPlayer GetPlayerById(NetworkPlayerId playerId)

Parameters

playerId NetworkPlayerId

Returns

NetworkPlayer

GetPlayerObject(NetworkPlayer)

Gets the the associated NetworkObject (player object) with this player.

public NetworkObject GetPlayerObject(NetworkPlayer player)

Parameters

player NetworkPlayer

Returns

NetworkObject

GetPlayerObject(NetworkPlayerId)

Gets the the associated NetworkObject (player object) with this player.

public NetworkObject GetPlayerObject(NetworkPlayerId id)

Parameters

id NetworkPlayerId

Returns

NetworkObject

GetPlayerObject<T>(NetworkPlayer)

Gets the the associated script (player object) of type T with this player.

public T GetPlayerObject<T>(NetworkPlayer player) where T : NetickBehaviour

Parameters

player NetworkPlayer

Returns

T

Type Parameters

T

GetPlayerObject<T>(NetworkPlayerId)

Gets the the associated script (player object) of type T with this player.

public T GetPlayerObject<T>(NetworkPlayerId id) where T : NetickBehaviour

Parameters

id NetworkPlayerId

Returns

T

Type Parameters

T

GetPrefab(string)

Gets a Network Prefab by name.

public GameObject GetPrefab(string name)

Parameters

name string

Returns

GameObject

The Network Prefab

InitializePool(NetworkObject, int, bool)

Initializes the pool for the specified prefab. After this method has been called for a certain prefab, all instances of that prefab will be recycled and reset when created/destroyed.

Note: this method should be called on OnStartup(NetworkSandbox), in other words, just after Netick has been started.

public void InitializePool(NetworkObject networkedPrefab, int preloadedAmount, bool hideInactiveMembers = false)

Parameters

networkedPrefab NetworkObject

Prefab to enable pooling for.

preloadedAmount int

How many instances to be preloaded.

hideInactiveMembers bool

Pass true to hide inactive pool members.

InitializePool(GameObject, int, bool)

public void InitializePool(GameObject networkedPrefab, int preloadedAmount, bool hideInactiveMembers = false)

Parameters

networkedPrefab GameObject
preloadedAmount int
hideInactiveMembers bool

Instantiate(GameObject, Vector3, Quaternion)

[Obsolete("This will be removed in the future, please use LocalInstantiate instead.")]
public GameObject Instantiate(GameObject prefab, Vector3 position, Quaternion rotation)

Parameters

prefab GameObject
position Vector3
rotation Quaternion

Returns

GameObject

Instantiate<T>(T, Vector3, Quaternion)

[Obsolete("This will be removed in the future, please use LocalInstantiate instead.")]
public T Instantiate<T>(T prefab, Vector3 position, Quaternion rotation) where T : MonoBehaviour

Parameters

prefab T
position Vector3
rotation Quaternion

Returns

T

Type Parameters

T

Kick(NetworkPlayer, ReadOnlySpan<byte>)

public void Kick(NetworkPlayer client, ReadOnlySpan<byte> kickData = default)

Parameters

client NetworkPlayer
kickData ReadOnlySpan<byte>

Kick(NetworkPlayerId, ReadOnlySpan<byte>)

[Server Only] Disconnects a client from the server.

public void Kick(NetworkPlayerId client, ReadOnlySpan<byte> kickData = default)

Parameters

client NetworkPlayerId

The client to be disconnected.

kickData ReadOnlySpan<byte>

Kick(ServerConnection, ReadOnlySpan<byte>)

public void Kick(ServerConnection client, ReadOnlySpan<byte> kickData = default)

Parameters

client ServerConnection
kickData ReadOnlySpan<byte>

LoadCustomSceneAsync(int, LoadSceneParameters)

public void LoadCustomSceneAsync(int customIndex, LoadSceneParameters loadSceneParameters)

Parameters

customIndex int
loadSceneParameters LoadSceneParameters

LoadSceneAsync(int, LoadSceneMode)

public void LoadSceneAsync(int buildIndex, LoadSceneMode loadSceneMode)

Parameters

buildIndex int
loadSceneMode LoadSceneMode

LoadSceneAsync(int, LoadSceneParameters)

public void LoadSceneAsync(int buildIndex, LoadSceneParameters loadSceneParameters)

Parameters

buildIndex int
loadSceneParameters LoadSceneParameters

LoadSceneAsync(string, LoadSceneMode)

[Server Only] Loads a scene asynchronously. This should only be called for scenes included in the build of the game.

public void LoadSceneAsync(string sceneName, LoadSceneMode loadSceneMode)

Parameters

sceneName string
loadSceneMode LoadSceneMode

LoadSceneAsync(string, LoadSceneParameters)

public void LoadSceneAsync(string sceneName, LoadSceneParameters loadSceneParameters)

Parameters

sceneName string
loadSceneParameters LoadSceneParameters

LocalInstantiate(GameObject)

public GameObject LocalInstantiate(GameObject prefab)

Parameters

prefab GameObject

Returns

GameObject

LocalInstantiate(GameObject, Vector3)

Instantiates a prefab. This must be called instead of UnityEngine.Object.Instantiate(UnityEngine.Object).

Note: this must be called only for non-networked prefabs. If you want to instantiate a network prefab, use NetworkInstantiate(GameObject, Vector3, Quaternion, NetworkPlayer) instead.

public GameObject LocalInstantiate(GameObject prefab, Vector3 position)

Parameters

prefab GameObject
position Vector3

Returns

GameObject

LocalInstantiate(GameObject, Vector3, Quaternion)

public GameObject LocalInstantiate(GameObject prefab, Vector3 position, Quaternion rotation)

Parameters

prefab GameObject
position Vector3
rotation Quaternion

Returns

GameObject

LocalInstantiate<T>(T)

public T LocalInstantiate<T>(T prefab) where T : MonoBehaviour

Parameters

prefab T

Returns

T

Type Parameters

T

LocalInstantiate<T>(T, Vector3)

public T LocalInstantiate<T>(T prefab, Vector3 position) where T : MonoBehaviour

Parameters

prefab T
position Vector3

Returns

T

Type Parameters

T

LocalInstantiate<T>(T, Vector3, Quaternion)

public T LocalInstantiate<T>(T prefab, Vector3 position, Quaternion rotation) where T : MonoBehaviour

Parameters

prefab T
position Vector3
rotation Quaternion

Returns

T

Type Parameters

T

Log(object)

public void Log(object message)

Parameters

message object

Log(object, Object)

public void Log(object message, Object context)

Parameters

message object
context Object

LogError(object)

public void LogError(object message)

Parameters

message object

LogError(object, Object)

public void LogError(object message, Object context)

Parameters

message object
context Object

LogWarning(object)

public void LogWarning(object message)

Parameters

message object

LogWarning(object, Object)

public void LogWarning(object message, Object context)

Parameters

message object
context Object

NetworkInstantiate(GameObject, NetworkPlayer)

public NetworkObject NetworkInstantiate(GameObject prefab, NetworkPlayer inputSource = null)

Parameters

prefab GameObject
inputSource NetworkPlayer

Returns

NetworkObject

NetworkInstantiate(GameObject, NetworkPlayerId)

public NetworkObject NetworkInstantiate(GameObject prefab, NetworkPlayerId inputSource)

Parameters

prefab GameObject
inputSource NetworkPlayerId

Returns

NetworkObject

NetworkInstantiate(GameObject, Vector3, NetworkPlayer)

public NetworkObject NetworkInstantiate(GameObject prefab, Vector3 position, NetworkPlayer inputSource = null)

Parameters

prefab GameObject
position Vector3
inputSource NetworkPlayer

Returns

NetworkObject

NetworkInstantiate(GameObject, Vector3, NetworkPlayerId)

public NetworkObject NetworkInstantiate(GameObject prefab, Vector3 position, NetworkPlayerId inputSource)

Parameters

prefab GameObject
position Vector3
inputSource NetworkPlayerId

Returns

NetworkObject

NetworkInstantiate(GameObject, Vector3, Quaternion, NetworkPlayer)

[Server Only] Instantiates a network prefab.

This must only be called on the server, since only the server can instantiate network prefabs.

Note: make sure the prefab has been registered.

Note: the specified input source will be given to every NetworkObject child of this prefab.

public NetworkObject NetworkInstantiate(GameObject prefab, Vector3 position, Quaternion rotation, NetworkPlayer inputSource = null)

Parameters

prefab GameObject
position Vector3
rotation Quaternion
inputSource NetworkPlayer

Returns

NetworkObject

NetworkInstantiate(GameObject, Vector3, Quaternion, NetworkPlayerId)

[Server Only] Instantiates a network prefab.

This must only be called on the server, since only the server can instantiate network prefabs.

Note: make sure the prefab has been registered.

Note: the specified input source will be given to every NetworkObject child of this prefab.

public NetworkObject NetworkInstantiate(GameObject prefab, Vector3 position, Quaternion rotation, NetworkPlayerId inputSource)

Parameters

prefab GameObject
position Vector3
rotation Quaternion
inputSource NetworkPlayerId

Returns

NetworkObject

NetworkInstantiate<T>(T, NetworkPlayer)

public T NetworkInstantiate<T>(T prefab, NetworkPlayer inputSource = null) where T : MonoBehaviour

Parameters

prefab T
inputSource NetworkPlayer

Returns

T

Type Parameters

T

NetworkInstantiate<T>(T, NetworkPlayerId)

public T NetworkInstantiate<T>(T prefab, NetworkPlayerId inputSource) where T : MonoBehaviour

Parameters

prefab T
inputSource NetworkPlayerId

Returns

T

Type Parameters

T

NetworkInstantiate<T>(T, Vector3, NetworkPlayer)

public T NetworkInstantiate<T>(T prefab, Vector3 position, NetworkPlayer inputSource = null) where T : MonoBehaviour

Parameters

prefab T
position Vector3
inputSource NetworkPlayer

Returns

T

Type Parameters

T

NetworkInstantiate<T>(T, Vector3, NetworkPlayerId)

public T NetworkInstantiate<T>(T prefab, Vector3 position, NetworkPlayerId inputSource) where T : MonoBehaviour

Parameters

prefab T
position Vector3
inputSource NetworkPlayerId

Returns

T

Type Parameters

T

NetworkInstantiate<T>(T, Vector3, Quaternion, NetworkPlayer)

[Server Only] Instantiates a network prefab.

This must only be called on the server, since only the server can instantiate network prefabs.

Note: make sure the prefab has been registered.

Note: the specified input source will be given to every NetworkObject child of this prefab.

public T NetworkInstantiate<T>(T prefab, Vector3 position, Quaternion rotation, NetworkPlayer inputSource = null) where T : MonoBehaviour

Parameters

prefab T
position Vector3
rotation Quaternion
inputSource NetworkPlayer

Returns

T

Type Parameters

T

NetworkInstantiate<T>(T, Vector3, Quaternion, NetworkPlayerId)

[Server Only] Instantiates a network prefab.

This must only be called on the server, since only the server can instantiate network prefabs.

Note: make sure the prefab has been registered.

Note: the specified input source will be given to every NetworkObject child of this prefab.

public T NetworkInstantiate<T>(T prefab, Vector3 position, Quaternion rotation, NetworkPlayerId inputSource) where T : MonoBehaviour

Parameters

prefab T
position Vector3
rotation Quaternion
inputSource NetworkPlayerId

Returns

T

Type Parameters

T

RefreshMatchList()

Requests an update to the match list. Only functional if the low-level transport has support for matchmaking.

public void RefreshMatchList()

RemoveFromLoop(NetworkObject)

public void RemoveFromLoop(NetworkObject obj)

Parameters

obj NetworkObject

SetComponentEnabled(Component, bool)

public void SetComponentEnabled(Component component, bool enabled)

Parameters

component Component
enabled bool

SetInput<T>(T, int)

Sets a specific input for the next tick.

public void SetInput<T>(T input, int index = 0) where T : unmanaged

Parameters

input T
index int

Type Parameters

T

SetPlayerObject(NetworkPlayer, NetworkObject)

public void SetPlayerObject(NetworkPlayer player, NetworkObject obj)

Parameters

player NetworkPlayer
obj NetworkObject

SetPlayerObject(NetworkPlayerId, NetworkObject)

[Server Only] Sets the the associated NetworkObject (player object) with this player.

public void SetPlayerObject(NetworkPlayerId id, NetworkObject obj)

Parameters

id NetworkPlayerId
obj NetworkObject

StartReplayPlayback(string)

[Client Only] Starts replaying. When not passed any address, Netick will automatically use the latest created file in Application.persistentDataPath/replays/gameVersion/.

public void StartReplayPlayback(string replayAddress = "")

Parameters

replayAddress string

StartReplayRecording(string)

[Server Only] Starts recording replay data. When not passed any address, Netick will use the current date and time for the replay file name, and the file will be stored in Application.persistentDataPath/replays/gameVersion/.

Note: to stop recording, use StopReplayRecording().

public void StartReplayRecording(string replayAddress = null)

Parameters

replayAddress string

StartTimer(float, bool)

public NetworkTimer StartTimer(float time, bool usePredictedTiming = true)

Parameters

time float
usePredictedTiming bool

Returns

NetworkTimer

StopReplayRecording()

Stops the current recording session. Awaiting this method ensures that recording has fully finished.

public Task StopReplayRecording()

Returns

Task

SwitchScene(int)

[Server Only] Switches to a different scene. This must be called instead of UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(int) or its variations. This should only be called for scenes included in the build of the game.

public void SwitchScene(int sceneBuildIndex)

Parameters

sceneBuildIndex int

SceneBuildIndex of the desired scene.

SwitchScene(string)

[Server Only] Switches to a different scene. This must be called instead of UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(int) or its variations. This should only be called for scenes included in the build of the game.

public void SwitchScene(string sceneName)

Parameters

sceneName string

TickToTime(Tick)

Converts ticks to time in seconds.

public float TickToTime(Tick tick)

Parameters

tick Tick

Returns

float

TickToTime(float)

Converts ticks to time in seconds.

public float TickToTime(float tick)

Parameters

tick float

Returns

float

TimeToTick(float)

Converts time (in seconds) to ticks.

public Tick TimeToTick(float time)

Parameters

time float

Returns

Tick

TryGetBehaviour<T>(NetworkBehaviourRef<T>, out T)

public bool TryGetBehaviour<T>(NetworkBehaviourRef<T> networkBehaviourRef, out T behaviour) where T : NetworkBehaviour

Parameters

networkBehaviourRef NetworkBehaviourRef<T>
behaviour T

Returns

bool

Type Parameters

T

TryGetBehaviour<T>(int, out T)

Tries to get the NetworkBehaviour of a NetworkObject with the specified id.

public bool TryGetBehaviour<T>(int id, out T behaviour) where T : NetworkBehaviour

Parameters

id int

The id of the network object

behaviour T

Returns

bool

Type Parameters

T

TryGetConnectionRefusalData(out ArraySegment<byte>)

public bool TryGetConnectionRefusalData(out ArraySegment<byte> data)

Parameters

data ArraySegment<byte>

Returns

bool

TryGetKickData(out ArraySegment<byte>)

public bool TryGetKickData(out ArraySegment<byte> data)

Parameters

data ArraySegment<byte>

Returns

bool

TryGetLocalPlayerObject(out NetworkObject)

Tries to get the the associated NetworkObject (player object) with the local player.

public bool TryGetLocalPlayerObject(out NetworkObject playerObject)

Parameters

playerObject NetworkObject

Returns

bool

TryGetLocalPlayerObject<T>(out T)

Tries to get the the associated script (player object) of type T with the local player.

public bool TryGetLocalPlayerObject<T>(out T playerObject) where T : NetickBehaviour

Parameters

playerObject T

Returns

bool

Type Parameters

T

TryGetObject(NetworkObjectRef, out NetworkObject)

public bool TryGetObject(NetworkObjectRef networkObjectRef, out NetworkObject obj)

Parameters

networkObjectRef NetworkObjectRef
obj NetworkObject

Returns

bool

TryGetObject(int, out NetworkObject)

Tries to get the NetworkObject with the specified id.

public bool TryGetObject(int id, out NetworkObject obj)

Parameters

id int

The id of the NetworkObject

obj NetworkObject

Returns

bool

TryGetPlayerObject(NetworkPlayer, out NetworkObject)

Tries to get the the associated NetworkObject (player object) with this player.

public bool TryGetPlayerObject(NetworkPlayer player, out NetworkObject playerObject)

Parameters

player NetworkPlayer
playerObject NetworkObject

Returns

bool

TryGetPlayerObject(NetworkPlayerId, out NetworkObject)

Tries to get the the associated NetworkObject (player object) with this player.

public bool TryGetPlayerObject(NetworkPlayerId id, out NetworkObject playerObject)

Parameters

id NetworkPlayerId
playerObject NetworkObject

Returns

bool

TryGetPlayerObject<T>(NetworkPlayer, out T)

Tries to get the the associated script (player object) of type T with this player.

public bool TryGetPlayerObject<T>(NetworkPlayer player, out T playerObject) where T : NetickBehaviour

Parameters

player NetworkPlayer
playerObject T

Returns

bool

Type Parameters

T

TryGetPlayerObject<T>(NetworkPlayerId, out T)

Tries to get the the associated script (player object) of type T with this player.

public bool TryGetPlayerObject<T>(NetworkPlayerId id, out T playerObject) where T : NetickBehaviour

Parameters

id NetworkPlayerId
playerObject T

Returns

bool

Type Parameters

T

UnloadCustomSceneAsync(int)

public void UnloadCustomSceneAsync(int customIndex)

Parameters

customIndex int

UnloadSceneAsync(int)

public void UnloadSceneAsync(int buildIndex)

Parameters

buildIndex int

UnloadSceneAsync(string)

[Server Only] Unloads a scene asynchronously.

public void UnloadSceneAsync(string sceneName)

Parameters

sceneName string

UnloadSceneAsync(Scene)

public void UnloadSceneAsync(Scene scene)

Parameters

scene Scene

Events

PostNetworkFixedUpdate

Called after all NetworkFixedUpdate methods have been executed.

Note: it's called with every resimulation on the client.

public event Action PostNetworkFixedUpdate

Event Type

Action

PostNetworkRender

Called after all NetworkRender methods have been executed.

public event Action PostNetworkRender

Event Type

Action

PostNetworkUpdate

Called after all NetworkUpdate methods have been executed.

public event Action PostNetworkUpdate

Event Type

Action

PreNetworkFixedUpdate

Called before any NetworkFixedUpdate method have been executed.

Note: it's called with every resimulation on the client.

public event Action PreNetworkFixedUpdate

Event Type

Action

PreNetworkRender

Called before any NetworkRender method have been executed.

public event Action PreNetworkRender

Event Type

Action

PreNetworkUpdate

Called before any NetworkUpdate method have been executed.

public event Action PreNetworkUpdate

Event Type

Action