Multiplayer API
Fast networking is necessary for powering shared AR experiences, particularly when synchronizing virtual content with real world objects that players can see through their camera feeds. Imagine an AR air hockey game where messages had a 0.5 second lag — a player could see their opponent move in real life and "miss" the puck while the game registers a hit.

Connections

Create a multiplayer AR experience you must use this API to create. This API provide you create or connect to server.

Connect By Discovery

1
public void ConnectToServerByDiscovery()
Copied!

Description

Suppose your are next to a friend. He starts a game in host mode and you want to join him. How will your phone locate his? Finding out his IP address is not exactly intuitive or something kids can do.
To solve this problem you can use Network Discovery. When your game starts, it sends a message in your current network asking "Is there any server available?". Any server within the same network will reply and provide information about how to connect to it.

Connect To Server

1
public void ConnectToServer(string _iPAddress, string _port)
Copied!

Description

Connect to a server by IPAddress and port.

Parameters

Connection
Description
_iPAddress
A server IP Address
_port
A server port

Disconnected

1
public void Disconnected()
Copied!

Description

Disconnect the client from the server.

Start Host Or Server Only

1
public void StartHost()
Copied!

Description

Create a server for clients.

Entity Properties

Entity Properties component will provide attribute for NetworkGameObject. Such as player's or enemy's health, level, name, etc.

Properties

Name
Type
Description
GetHealth
Int
Current entity health value
GetPlayerLevel
Int
Current entity level value
GetPlayerName
String
Current entity name value
GetCustomProperties
String
Current entity custom properties value

Public fields

Name
Type
Description
Sender
NetworkIdentity
The network message owner

Public Methods

CmdSubtractHealth

1
public void CmdSubtractHealth(int _newValue, NetworkIdentity _sender)
Copied!

Description

Change the entity health value. You can register the Health value change event to listen the value change.

Parameters

Connection
Type
Description
_newValue
Int
The value of health to be subtracted
_sender
NetworkIdentity
The sender of the operation. e.g. Player attack to enemy, the sender is player

CmdAddHealth

1
public void CmdAddHealth(int _newValue, NetworkIdentity _sender)
Copied!

Description

Change the entity health value. You can register the Health value change event to listen the value change.

Parameters

Connection
Type
Description
_newValue
Int
The value of health to be subtracted
_sender
NetworkIdentity
The sender of the operation. e.g. Player attack to enemy, the sender is player

CmdLevelUp

1
public void CmdLevelUp(int _additionLevel, NetworkIdentity _sender)
Copied!

Description

Change the entity level value. You can register the Level value change event to listen the value change.

Parameters

Connection
Type
Description
_additionLevel
Int
The value of level to be up
_sender
NetworkIdentity
The sender of the operation. e.g. Player attack to enemy, the sender is player

CmdDegradeLevel

1
public void CmdDegradeLevel(int _level, NetworkIdentity _sender)
Copied!

Description

Change the entity level value. You can register the Level value change event to listen the value change.

Parameters

Connection
Type
Description
_level
Int
The value of level to be degrade
_sender
NetworkIdentity
The sender of the operation. e.g. Player attack to enemy, the sender is player

CmdSetPlayerName

1
public void CmdSetPlayerName(string _name, NetworkIdentity _sender)
Copied!

Description

Name your players and monsters. You can register the PlayerName value change event to listen the value change.

Parameters

Connection
Type
Description
_name
Int
The value of health to be subtracted
_sender
NetworkIdentity
The sender of the operation. e.g. Player attack to enemy, the sender is player

CmdUpdateCustomProperties

1
public void CmdUpdateCustomProperties(string _customProperties, NetworkIdentity _sender)
Copied!

Description

In addition to the above attributes, you can also add additional attributes.You also can register the CustomProperties value change event to listen the value change.

Parameters

Connection
Type
Description
_customProperties
Int
Incoming custom properties value
_sender
NetworkIdentity
The sender of the operation

Event Receivers(Callback)

Event Receiver uses a commissioned design model. The purpose is to respond to RPC and Attribute synchronization in the network framework. AR-MOD is divided into two parts: event realization and event trigger
  • Register all events callback must be in OnEnable or Awake

Example

In this example we are divided into two parts:
  1. 1.
    We register the CmdTransformDataAction on OnEnable or Awake method and implement the event logic
  2. 2.
    Call the CmdTransforDataSender (Execute the logic on client)
PlayerEntity.cs
1
//Register the event for spawn bullet on each clients
2
//and sync the initialization position, rotation.
3
remoteActions.CmdTransformDataAction ??= new Dictionary<string, Action<TransformData, NetworkIdentity>>();
4
remoteActions.CmdTransformDataAction.TryAdd(CONST_SHOOTING_EVENT, (_data, _sender) =>
5
{
6
var tmp_Bullet = Instantiate(ARMODServerBridge.GetBridge()
7
.GetNetworkPrefab(Bullet));
8
var tmp_BulletTrans = tmp_Bullet.transform;
9
tmp_BulletTrans.SetParent(arSpace.transform, true);
10
tmp_BulletTrans.localPosition = _data.Position;
11
tmp_BulletTrans.localRotation = _data.Rotation;
12
ARMODServerBridge.GetBridge().SpawnSync(tmp_Bullet);
13
tmp_Bullet.GetComponent<Projectile>().owner = _sender;
14
15
//Play muzzle effect when shooting
16
remoteActions.RpcClientRpcSender(CONST_PLAY_MUZZLE_EFFECT_EVENT, _sender);
17
});
Copied!
UICanvas.cs
1
/// <summary>
2
/// Shoot projectile [Run on server,send from client]
3
/// </summary>
4
internal void SendShootCommand()
5
{
6
var tmp_LocalRotation = selfTran1.localRotation;
7
var tmp_TransData = new TransformData
8
{
9
Position = selfTran1.localPosition + (tmp_LocalRotation * MuzzleTrans.localPosition),
10
Rotation = tmp_LocalRotation
11
};
12
13
//Trigger event
14
remoteActions.CmdTransformDataSender(CONST_SHOOTING_EVENT, tmp_TransData, this.NetworkIdentity);
15
}
Copied!

Register Client Event Receiver

1
public Dictionary<string, Action<string, NetworkIdentity>> ClientStringAction;
2
public Dictionary<string, Action<float, NetworkIdentity>> ClientFloatAction;
3
public Dictionary<string, Action<int, NetworkIdentity>> ClientIntAction;
4
public Dictionary<string, Action<bool, NetworkIdentity>> ClientBoolAction;
5
public Dictionary<string, Action<Vector3, NetworkIdentity>> ClientVector3Action;
6
public Dictionary<string, Action<Quaternion, NetworkIdentity>> ClientQuaternionAction;
7
public Dictionary<string, Action<GameObject, NetworkIdentity>> ClientGameObjectAction;
8
public Dictionary<string, Action<TransformData, NetworkIdentity>> ClientTransformDataAction;
9
public Dictionary<string, Action<NetworkIdentity>> ClientAction;
Copied!

Description

Register the client event receiver to listen client network callbacks.
Only a Client can call the method (throws a warning or an error when called on the server).
Name
Type
Description
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Register ClientCallback Receiver

1
public Dictionary<string, Action<string, NetworkIdentity>> ClientCallbackStringAction;
2
public Dictionary<string, Action<float, NetworkIdentity>> ClientCallbackFloatAction;
3
public Dictionary<string, Action<int, NetworkIdentity>> ClientCallbackIntAction;
4
public Dictionary<string, Action<bool, NetworkIdentity>> ClientCallbackBoolAction;
5
public Dictionary<string, Action<Vector3, NetworkIdentity>> ClientCallbackVector3Action;
6
public Dictionary<string, Action<Quaternion, NetworkIdentity>> ClientCallbackQuaternionAction;
7
public Dictionary<string, Action<GameObject, NetworkIdentity>> ClientCallbackGameObjectAction;
8
public Dictionary<string, Action<TransformData, NetworkIdentity>> ClientCallbackTransformDataAction;
9
public Dictionary<string, Action<NetworkIdentity>> ClientCallbackAction;
Copied!

Description

Register the client event receiver to listen client network callbacks.
Same as Client but does not throw warning when called on server.

Parameters

Name
Type
Description
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Register Server Receiver

1
public Dictionary<string, Action<NetworkIdentity>> ServerAction;
2
public Dictionary<string, Action<string, NetworkIdentity>> ServerStringAction;
3
public Dictionary<string, Action<float, NetworkIdentity>> ServerFloatAction;
4
public Dictionary<string, Action<int, NetworkIdentity>> ServerIntAction;
5
public Dictionary<string, Action<bool, NetworkIdentity>> ServerBoolAction;
6
public Dictionary<string, Action<Vector3, NetworkIdentity>> ServerVector3Action;
7
public Dictionary<string, Action<Quaternion, NetworkIdentity>> ServerQuaternionAction;
8
public Dictionary<string, Action<GameObject, NetworkIdentity>> ServerGameObjectAction;
9
public Dictionary<string, Action<TransformData, NetworkIdentity>> ServerTransformDataAction;
Copied!

Description

Register the server event receiver to listen client network callbacks.
Only a server can call the method (throws a warning or an error when called on a client).

Parameters

Name
Type
Description
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Register ServerCallback Receiver

1
public Dictionary<string, Action<string, NetworkIdentity>> ServerCallbackStringAction;
2
public Dictionary<string, Action<float, NetworkIdentity>> ServerCallbackFloatAction;
3
public Dictionary<string, Action<int, NetworkIdentity>> ServerCallbackIntAction;
4
public Dictionary<string, Action<bool, NetworkIdentity>> ServerCallbackBoolAction;
5
public Dictionary<string, Action<Vector3, NetworkIdentity>> ServerCallbackVector3Action;
6
public Dictionary<string, Action<Quaternion, NetworkIdentity>> ServerCallbackQuaternionAction;
7
public Dictionary<string, Action<GameObject, NetworkIdentity>> ServerCallbackGameObjectAction;
8
public Dictionary<string, Action<TransformData, NetworkIdentity>> ServerCallbackTransformDataAction;
9
public Dictionary<string, Action<NetworkIdentity>> ServerCallbackAction;
Copied!

Description

Register the server event receiver to listen client network callbacks.
Same as Server but does not throw warning when called on client.

Parameters

Name
Type
Description
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Register CustomPropertiesSynced Receiver

1
public Action<string, NetworkIdentity> CustomPropertiesSyncedCallback;
Copied!

Description

Register the customProperties event receiver to listen EntityPropertiesSync component's custom properties field change and synced variable value.

Return

String Final customProperties

Register Entity Health Synced Receivert

1
public Action<float, NetworkIdentity> HealthSyncedCallback;
Copied!

Description

Register the health event receiver to listen EntityPropertiesSync component's health field change and sync variable value.

Return

Int Final health value

Register Entity Level Receiver

1
public Action<int, NetworkIdentity> PlayerLevelSyncedCallback;
Copied!

Description

Register the level event receiver to listen EntityPropertiesSync component's level field change and synced variable value.

Return

Int return final level value.

Register Entity Name Receiver

1
public Action<string, NetworkIdentity> PlayerNameSyncedCallback;
Copied!

Description

Register the level event receiver to listen EntityPropertiesSync component's level field change and synced variable value.

Return

String Final entity name value

Register NetworkStatus Receiver

Register the level event receiver to listen Network Status.

Return

Server Side
Type(Both)
Client Side
OnStartServer
String
OnStartClient
OnServerReady
String
OnStopClient
OnServerAddPlayer
String
OnClientNotReady
OnServerDisconnect
String
OnClientConnect
OnServerConnect
String
OnClientDisconnect

Register Synchronizer Receiver

1
public void RegisterValueSyncedCallback(Action<Vector3,NetworkIdentity> _callback)
2
public void RegisterValueSyncedCallback(Action<string,NetworkIdentity> _callback)
3
public void RegisterValueSyncedCallback(Action<Quaternion,NetworkIdentity> _callback )
4
public void RegisterValueSyncedCallback(Action<float,NetworkIdentity> _callback)
5
public void RegisterValueSyncedCallback(Action<bool, NetworkIdentity> _callback)
Copied!

Description

Register the level event receiver to listen change and synced value.

Parameters

Connection
Type
Description
Action
Delegate
The value synced callback

Register ClientRPC Receiver

1
public Dictionary<string, Action<string, NetworkIdentity>> ClientRpcStringAction;
2
public Dictionary<string, Action<float, NetworkIdentity>> ClientRpcFloatAction;
3
public Dictionary<string, Action<int, NetworkIdentity>> ClientRpcIntAction;
4
public Dictionary<string, Action<bool, NetworkIdentity>> ClientRpcBoolAction;
5
public Dictionary<string, Action<Vector3, NetworkIdentity>> ClientRpcVector3Action;
6
public Dictionary<string, Action<Quaternion, NetworkIdentity>> ClientRpcQuaternionAction;
7
public Dictionary<string, Action<GameObject, NetworkIdentity>> ClientRpcGameObjectAction;
8
public Dictionary<string, Action<TransformData, NetworkIdentity>> ClientRpcTransformDataAction;
9
public Dictionary<string, Action<NetworkIdentity>> ClientRpcAction;
Copied!

Description

Register the client remote action receiver to listen client rpc event. ClientRpc calls are sent from objects on the server to objects on clients. They can be sent from any server object with a NetworkIdentity that has been spawned. Since the server has authority, then there no security issues with server objects being able to send these calls.

Return

Name
Type
Description
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Register Command Receiver

1
public Dictionary<string, Action<string, NetworkIdentity>> CmdStringAction;
2
public Dictionary<string, Action<float, NetworkIdentity>> CmdFloatAction;
3
public Dictionary<string, Action<int, NetworkIdentity>> CmdIntAction;
4
public Dictionary<string, Action<bool, NetworkIdentity>> CmdBoolAction;
5
public Dictionary<string, Action<Vector3, NetworkIdentity>> CmdVector3Action;
6
public Dictionary<string, Action<Quaternion, NetworkIdentity>> CmdQuaternionAction;
7
public Dictionary<string, Action<GameObject, NetworkIdentity>> CmdGameObjectAction;
8
public Dictionary<string, Action<TransformData, NetworkIdentity>> CmdTransformDataAction;
9
public Dictionary<string, Action<NetworkIdentity>> CmdAction;
Copied!

Description

Register the command remote action receiver to listen command event.Commands are sent from player objects on the client to player objects on the server. For security, Commands can only be sent from YOUR player object by default, so you cannot control the objects of other players.

Parameters

Name
Type
Description
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Register TargetRPC Receiver

1
public Dictionary<string, Action<string, NetworkIdentity>> TargetRpcStringAction;
2
public Dictionary<string, Action<float, NetworkIdentity>> TargetRpcFloatAction;
3
public Dictionary<string, Action<int, NetworkIdentity>> TargetRpcIntAction;
4
public Dictionary<string, Action<bool, NetworkIdentity>> TargetRpcBoolAction;
5
public Dictionary<string, Action<Vector3, NetworkIdentity>> TargetRpcVector3Action;
6
public Dictionary<string, Action<Quaternion, NetworkIdentity>> TargetRpcQuaternionAction;
7
public Dictionary<string, Action<GameObject, NetworkIdentity>> TargetRpcGameObjectAction;
8
public Dictionary<string, Action<TransformData, NetworkIdentity>> TargetRpcTransformDataAction;
9
public Dictionary<string, Action<NetworkIdentity>> TargetRpcAction;
Copied!

Description

Register the target remote action receiver to listen target rpc event.TargetRpc functions are called by user code on the server, and then invoked on the corresponding client object on the client of the specified NetworkConnection.

Parameters

Name
Type
Description
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Network Attributes Trigger

Client Trigger

1
public void ClientSender(string _eventName, NetworkIdentity _sender)
2
public void ClientStringSender(string _eventName, string _parameter, NetworkIdentity _sender)
3
public void ClientFloatSender(string _eventName, float _parameter, NetworkIdentity _sender)
4
public void ClientIntSender(string _eventName, int _parameter, NetworkIdentity _sender)
5
public void ClientBoolSender(string _eventName, bool _parameter, NetworkIdentity _sender)
6
public void ClientVector3Sender(string _eventName, Vector3 _parameter, NetworkIdentity _sender)
7
public void ClientQuaternionSender(string _eventName, Quaternion _parameter, NetworkIdentity _sender)
8
public void ClientGameObjectSender(string _eventName, GameObject _parameter, NetworkIdentity _sender)
9
public void ClientTransformDataSender(string _eventName, TransformData _parameter, NetworkIdentity _sender)
Copied!

Description

Only a Client can call the method (throws a warning or an error when called on the server).
There have None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),
TransformData.

Parameters

Connection
Type
Description
_eventName
String
Key of event dictnary
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Client Callback Trigger

1
public void ClientCallbackSender(string _eventName, NetworkIdentity _sender)
2
public void ClientCallbackStringSender(string _eventName, string _parameter, NetworkIdentity _sender)
3
public void ClientCallbackFloatSender(string _eventName, float _parameter, NetworkIdentity _sender)
4
public void ClientCallbackIntSender(string _eventName, int _parameter, NetworkIdentity _sender)
5
public void ClientCallbackBoolSender(string _eventName, bool _parameter, NetworkIdentity _sender)
6
public void ClientCallbackVector3Sender(string _eventName, Vector3 _parameter, NetworkIdentity _sender)
7
public void ClientCallbackQuaternionSender(string _eventName, Quaternion _parameter, NetworkIdentity _sender)
8
public void ClientCallbackGameObjectSender(string _eventName, GameObject _parameter, NetworkIdentity _sender)
9
public void ClientCallbackTransformDataSender(string _eventName, TransformData _parameter,NetworkIdentity _sender)
Copied!

Description

Same as Client but does not throw warning when called on server.
There have None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),
TransformData.

Parameters

Connection
Type
Description
_eventName
String
Key of event dictnary
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Server Trigger

1
public void ServerStringSender(string _eventName, string _parameter, NetworkIdentity _sender)
2
public void ServerFloatSender(string _eventName, float _parameter, NetworkIdentity _sender)
3
public void ServerIntSender(string _eventName, int _parameter, NetworkIdentity _sender)
4
public void ServerBoolSender(string _eventName, bool _parameter, NetworkIdentity _sender)
5
public void ServerVector3Sender(string _eventName, Vector3 _parameter, NetworkIdentity _sender)
6
public void ServerQuaternionSender(string _eventName, Quaternion _parameter, NetworkIdentity _sender)
7
public void ServerSender(string _eventName, NetworkIdentity _sender)
8
public void ServerGameObjectSender(string _eventName, GameObject _parameter, NetworkIdentity _sender)
9
public void ServerTransformDataSender(string _eventName, TransformData _parameter, NetworkIdentity _sender)
Copied!

Description

Only a server can call the method (throws a warning or an error when called on a client).
There have None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),
TransformData.

Parameters

Connection
Type
Description
_eventName
String
Key of event dictnary
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Server Callback Trigger

1
public void ServerCallbackSender(string _eventName, NetworkIdentity _sender)
2
public void ServerCallbackSender(string _eventName, string _parameter, NetworkIdentity _sender)
3
public void ServerCallbackSender(string _eventName, float _parameter, NetworkIdentity _sender)
4
public void ServerCallbackSender(string _eventName, int _parameter, NetworkIdentity _sender)
5
public void ServerCallbackSender(string _eventName, bool _parameter, NetworkIdentity _sender)
6
public void ServerCallbackSender(string _eventName, Vector3 _parameter, NetworkIdentity _sender)
7
public void ServerCallbackSender(string _eventName, Quaternion _parameter, NetworkIdentity _sender)
8
public void ServerCallbackSender(string _eventName, GameObject _parameter, NetworkIdentity _sender)
9
public void ServerCallbackSender(string _eventName, TransformData _parameter, NetworkIdentity _sender)
Copied!

Description

Same as Server but does not throw warning when called on client.
There have None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),
TransformData.

Parameters

Connection
Type
Description
_eventName
String
Key of event dictnary
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Remote Actions Trigger

The network system has ways to perform actions across the network. These type of actions are sometimes called Remote Procedure Calls. There are two types of RPCs in the network system, Commands - which are called from the client and run on the server; and ClientRpc calls - which are called on the server and run on clients.

Client RPC Trigger

1
public void RpcClientRpcSender(string _eventName, NetworkIdentity _sender)
2
public void RpcClientRpcStringSender(string _eventName, string _parameter, NetworkIdentity _sender)
3
public void RpcClientRpcFloatSender(string _eventName, float _parameter, NetworkIdentity _sender)
4
public void RpcClientRpcIntSender(string _eventName, int _parameter, NetworkIdentity _sender)
5
public void RpcClientRpcBoolSender(string _eventName, bool _parameter, NetworkIdentity _sender)
6
public void RpcClientRpcVector3Sender(string _eventName, Vector3 _parameter, NetworkIdentity _sender)
7
public void RpcClientRpcQuaternionSender(string _eventName, Quaternion _parameter, NetworkIdentity _sender)
8
public void RpcClientRpcGameObjectSender(string _eventName, GameObject _parameter, NetworkIdentity _sender)
9
public void RpcClientRpcTransformDataSender(string _eventName, TransformData _parameter,NetworkIdentity _sender)
Copied!

Description

ClientRpc calls are sent from objects on the server to objects on clients. They can be sent from any server object with a NetworkIdentity that has been spawned. Since the server has authority, then there no security issues with server objects being able to send these calls.
There have None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),
TransformData.

Parameters

Connection
Type
Description
_eventName
String
Key of event dictnary
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Command Trigger

1
public void CmdSender(string _eventName, NetworkIdentity _sender)
2
public void CmdStringSender(string _eventName, string _parameter, NetworkIdentity _sender)
3
public void CmdVector3Sender(string _eventName, Vector3 _parameter, NetworkIdentity _sender)
4
public void CmdQuaternionSender(string _eventName, Quaternion _parameter, NetworkIdentity _sender)
5
public void CmdFloatSender(string _eventName, float _parameter, NetworkIdentity _sender)
6
public void CmdBoolSender(string _eventName, bool _parameter, NetworkIdentity _sender)
7
public void CmdIntSender(string _eventName, int _parameter, NetworkIdentity _sender)
8
public void CmdGameObjectSender(string _eventName, GameObject _parameter, NetworkIdentity _sender)
9
public void CmdTransformDataSender(string _eventName, TransformData _parameter, NetworkIdentity _sender)
Copied!

Description

Commands Trigger are sent from player objects on the client to player objects on the server. For security, Commands can only be sent from YOUR player object by default, so you cannot control the objects of other players.
There have None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),
TransformData.

Parameters

Connection
Type
Description
_eventName
String
Key of event dictnary
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Target RPC Trigger

1
public void TargetRpcSender(string _eventName, NetworkIdentity _sender)
2
public void TargetRpcStringSender(string _eventName, string _parameter, NetworkIdentity _sender)
3
public void TargetRpcFloatSender(string _eventName, float _parameter, NetworkIdentity _sender)
4
public void TargetRpcIntSender(string _eventName, int _parameter, NetworkIdentity _sender)
5
public void TargetRpcBoolSender(string _eventName, bool _parameter, NetworkIdentity _sender)
6
public void TargetRpcVector3Sender(string _eventName, Vector3 _parameter, NetworkIdentity _sender)
7
public void TargetRpcQuaternionSender(string _eventName, Quaternion _parameter, NetworkIdentity _sender)
8
public void TargetRpcGameObjectSender(string _eventName, GameObject _parameter, NetworkIdentity _sender)
9
public void TargetRpcTransformDataSender(string _eventName, TransformData _parameter, NetworkIdentity _sender)
Copied!

Description

TargetRpc functions are called by user code on the server, and then invoked on the corresponding client object on the client of the specified NetworkConnection. The arguments to the RPC call are serialized across the network, so that the client function is invoked with the same values as the function on the server.
There have None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),
TransformData.

Parameters

Connection
Type
Description
_eventName
String
Key of event dictnary
_parameter
Int/Float/String/Bool/TransformData/Vector3/Quaternion/NetkGameObject
Incomming data
_sender
NetworkIdentity
Who sent this remote action

Synchronizer

Number Synchronizer

1
public void CmdModifyValue(float _newValue,NetworkIdentity _sender)
Copied!

Description

Synchronous the value to remote client or server. Like the Syncvar attribute

Parameters

Connection
Type
Description
_newValue
Float
Incomming dat
_sender
NetworkIdentity
Who sent this remote action

Quaternion Synchronizer

1
public void CmdModifyValue(Quaternion _newValue,NetworkIdentity _sender)
Copied!

Description

Synchronous the value to remote client or server. Like the Syncvar attribute

Parameters

Connection
Type
Description
_newValue
Quaternion
Incomming dat
_sender
NetworkIdentity
Who sent this remote action

String Synchronizer

1
public void CmdModifyValue(string _newValue,NetworkIdentity _sender)
Copied!

Description

Synchronous the value to remote client or server. Like the Syncvar attribute

Parameters

Connection
Type
Description
_newValue
String
Incomming dat
_sender
NetworkIdentity
Who sent this remote action

Vector3 Synchronizer

1
public void CmdModifyValue(Vector3 _vector3,NetworkIdentity _sender)
Copied!

Description

Synchronous the value to remote client or server. Like the Syncvar attribute

Parameters

Connection
Type
Description
_newValue
Vector3
Incomming dat
_sender
NetworkIdentity
Who sent this remote action

Bool Synchronizer

1
pupublic void CmdModifyValue(bool _newValue, NetworkIdentity _sender)
Copied!

Description

Synchronous the value to remote client or server. Like the Syncvar attribute

Parameters

Connection
Type
Description
_newValue
Bool
Incomming dat
_sender
NetworkIdentity
Who sent this remote action

Utility

Assign ClientAuthority

1
public void AssignClientAuthority(NetworkIdentity _assignedObject, NetworkIdentity _connection)
Copied!

Description

Assign control of an object to a client via the client's NetworkConnection. This causes hasAuthority to be set on the client that owns the object, and NetworkBehaviour.OnStartAuthority will be called on that client.This object then will be in the NetworkConnection.clientOwnedObjects list for the connection. Authority can be removed with RemoveClientAuthority. Only one client can own an object at any time. This does not need to be called for player objects, as their authority is setup automatically.

Parameters

Connection
Type
Description
_assignedObject
NetworkIdentity
Network GameObject that need to be reassigned
_connection
NetworkIdentity
Authorized user

Is Server

1
var tmp_NetworkIdentity = getcomponent<NetworkIdentity>();
2
tmp_NetworkIdentity.isServer
Copied!

Description

Check current network gameobject is create from spawn.

Return

True if this game object is running on the server, and has been spawned. False otherwise.

Has Authority

1
var tmp_NetworkIdentity = getcomponent<NetworkIdentity>();
2
tmp_NetworkIdentity.hasAuthority
Copied!

Description

Check current game object has authority in this side.NetworkIdentity required

Return

True or False.

Get LocalIP

1
public string GetLocalIP()
Copied!

Description

Get current device IP Address(IPV4).

Return

String IP Address. e.g. 192.168.0.100

Get LocalPlayer

1
public GameObject GetLocalPlayer()
Copied!
Access the local player game object.

Return

GameObject

Get LocalNetworkConnection

1
public NetworkConnection GetLocalNetworkConnection()
Copied!

Description

Get Information about the player connecting to the server.
Return
Network Connection To Server

Get NetworkPrefab

1
public GameObject GetNetworkPrefab(string _prefabName)
Copied!

Description

Get the network prefab from registration list.

Return

Network GameObject

Parameters

Connection
Type
Description
_prefabName
String
The name of game object in the registration list

UnSpawnNetworkObject

1
public void UnSpawnNetworkObject(GameObject _entity)
Copied!

Description

Destroy network gameobject from network.

Parameters

Connection
Type
Description
_entity
GameObject
Destroy the Network gameobject over the network

Register Prefab

1
public void RegisterPrefab(GameObject _needToRegisterPrefab)
Copied!

Description

Register the prefab to spawning system.

Parameters

Connection
Type
Description
_needToRegisterPrefab
GameObject
Need to spawn on all client you must register the gameobject first

Spawn Player

1
public void SpawnPlayer(string _prefabName)
Copied!

Description

Create the local player on the network.

Parameters

Connection
Type
Description
_prefabName
GameObject
The player character

Spawn Prefab

1
public void SpawnPrefab(string _prefabName)
Copied!

Description

The server manages spawned game objects alongside all other networked game objects,so that if another client joins the game later, the server can spawn the game objects on that client.

Parameters

Connection
Type
Description
_prefabName
GameObject
The network gameobject want to spawn

Spawn Sync

1
public void SpawnSync(GameObject _gameObject, NetworkConnection _connection = null)
Copied!

Description

Synchronize to other clients when game object is instanced.

Parameters

Connection
Type
Description
_gameObject
GameObject
Need to synced gameobject
_connection
NetworkIdentity
owner
Last modified 1mo ago