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 Units

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

Connect By Discovery Unit

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 Unit

Description

Connect to a server by IPAddress and port.

Parameters

Connection
Description
IP Address
A server IP Address
Port
A server port

Disconnected Unit

Description

Disconnect the client from the server.

Start Host Or Server Only Unit

Description

Create a server for clients.

Parameters

Connection
Description
Server Type
What kind of server will be created.
ServerType
Description
Host
Create a server and client on the same device.
Server Only
Only createt a server.

Entity Properties Units

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

Get EntityProperties Unit

Description

Try acquire the NetworkPropertiesSync component.

Return

NetworkPropertiesSync return the component of networkpropertiesSync.

Parameters

Connection
Description
Target
which gameobject has networkpropertiessync component.

Health Calculation Trigger Unit

Description

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

Parameters

Connection
Type
Description
Health
Int
Incoming health value
EntityProperties
NetworkPropertiesSync
NetworkPropertiesSync component(default in current gameObject)
CalculationType
Enum
Increase and decrease the health value(Not incoming health value)
Sender
NetworkIdentity
The sender of the operation. e.g. Player attack to enemy, the sender is player.

Level Calculation Trigger Unit

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
Incoming level value
EntityProperties
NetworkPropertiesSync
NetworkPropertiesSync component(default in current gameObject)
CalculationType
Enum
Increase and decrease the health value(Not incoming level value)
Sender
NetworkIdentity
The sender of the operation. e.g. You upgrade your role and let all clients know that the sender is yourself.

Set PlayerName Trigger Unit

Description

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

Parameters

Connection
Type
Description
EntityName
String
Incoming name value
EntityProperties
NetworkPropertiesSync
NetworkPropertiesSync component(default in current gameObject)
Sender
NetworkIdentity
The sender of the operation. e.g. You setup or upgrade your user name and let all clients know that the sender is yourself.

Update CustomProperties Trigger Unit

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
Custom Properties
String
Incoming custom properties value
EntityProperties
NetworkPropertiesSync
NetworkPropertiesSync component(default in current gameObject)
Sender
NetworkIdentity
The sender of the operation.

Event Receivers Units

Event Receiver unit uses a commissioned design model. The purpose is to respond to RPC and Attribute synchronization in the network framework. AR-MOD is divided into three parts: event monitoring , event realization and event trigger.
  • Register all event listen must be in OnEnable .
  • EventName with CustomEventName must be the same.
  • The return value of all units is the same as the input parameter type of the monitoring unit you set.

Example

In this example we are divided into three parts:
  1. 1.
    We register the ClientEvent on OnEnable method and set the type to int
  2. 2.
    Implement the SyncInt Event
  3. 3.
    Trigger the client event(Execute the logic on client)
a network event example

Register Client Event Receiver Unit

Description

Register the client event receiver to listen client network callbacks.
There have None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),
TransformData unit.
Only a Client can call the method (throws a warning or an error when called on the server).

Parameters

Connection
Type
Description
EventTarget
GameObject
Where is the EventName event
Parameter
object(System)
Incomming data
EventName
String
Name for response event
Attributes
NetworkAttribute
NetworkAttribute component
Sender
NetworkIdentity
Who sent this remote action

Register ClientCallback Receiver Unit

Description

Register the client event receiver to listen client network callbacks.
There have None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),
TransformData unit.
Same as Client but does not throw warning when called on server.

Parameters

Connection
Type
Description
EventTarget
GameObject
Where is the EventName event
Parameter
object(System)
Incomming data
EventName
String
Name for response event
Attributes
NetworkAttribute
NetworkAttribute component
Sender
NetworkIdentity
Who sent this remote action

Register Server Receiver Unit

Description

Register the server event receiver to listen client network callbacks.
There have None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),
TransformData unit.
Only a server can call the method (throws a warning or an error when called on a client).

Parameters

Connection
Type
Description
EventTarget
GameObject
Where is the EventName event
Parameter
object(System)
Incomming data
EventName
String
Name for response event
Attributes
NetworkAttribute
NetworkAttribute component
Sender
NetworkIdentity
Who sent this remote action

Register ServerCallback Receiver Unit

Description

Register the server event receiver to listen client network callbacks.

Return

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

Parameters

Connection
Type
Description
EventTarget
GameObject
Where is the EventName event
Parameter
object(System)
Incomming data
EventName
String
Name for response event
Attributes
NetworkAttribute
NetworkAttribute component
Sender
NetworkIdentity
Who sent this remote action

Register Enetity CustomProperties Receiver Unit

Description

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

Return

String Final customProperties

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
EventName
String
Name for response event
Synchronizer
NetworkProperties
NetworkProperties Sync component

Register Entity Health Receiver Unit

Description

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

Return

Int Final health value

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
EventName
String
Name for response event
Synchronizer
NetworkProperties
NetworkProperties Sync component

Register Entity Level Receiver Unit

Description

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

Return

Int return final level value.

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
EventName
String
Name for response event
Synchronizer
NetworkProperties
NetworkProperties Sync component

Register Entity Name Receiver Unit

Description

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

Return

String Final entity name value

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
EventName
String
Name for response event
Synchronizer
NetworkProperties
NetworkProperties Sync component

Register NetworkStatus Receiver Unit

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 Unit

Description

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

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
Type
Int,Float,Bool,String,Vector3,Quaternion
Want to synchronize value types
Synchronizer
NetworkProperties
NetworkProperties Sync component

Register ClientRPC Receiver Unit

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.

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
Type
None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),TransformData.
Want to synchronize value types
EventName
String
Name for response event
Remote Action
NetworkRemoteAction
Remote action component

Register Command Receiver Unit

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

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
Type
None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),TransformData.
Want to synchronize value types
EventName
String
Name for response event
Remote Action
NetworkRemoteAction
Remote action component

Register TargetRPC Receiver Unit

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

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
Type
None,Int,Float,String,Vector3,Quaternion,GameObject(NetworkGameObject),TransformData.
Want to synchronize value types
EventName
String
Name for response event
Remote Action
NetworkRemoteAction
Remote action component

Network Attributes Trigger Units

Client Trigger

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

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
Parameter
object(System)
Incomming data
EventName
String
Name for response event
Remote Action
NetworkRemoteAction
Remote action component
Sender
NetworkIdentity
Who sent this remote action

Client Callback Trigger Unit

Description

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

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
Parameter
object(System)
Incomming data
EventName
String
Name for response event
Remote Action
NetworkRemoteAction
Remote action component
Sender
NetworkIdentity
Who sent this remote action

Server Trigger Unit

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

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
Parameter
object(System)
Incomming data
EventName
String
Name for response event
Remote Action
NetworkRemoteAction
Remote action component
Sender
NetworkIdentity
Who sent this remote action

Server Callback Trigger Unit

Description

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

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
Parameter
object(System)
Incomming data
EventName
String
Name for response event
Remote Action
NetworkRemoteAction
Remote action component
Sender
NetworkIdentity
Who sent this remote action

Get Network Attribute Unit

Description

Get the NetworkAttribute from the target object.

Return

NetworkAttribute

Parameters

Connection
Description
Target
Where is the NetworkAttribute component.

Remote Actions Trigger Units

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 Unit

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

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
Parameter
object(System)
Incomming data
EventName
String
Name for response event
Remote Action
NetworkRemoteAction
Remote action component
Sender
NetworkIdentity
Who sent this remote action

Command Trigger Unit

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

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
Parameter
object(System)
Incomming data
EventName
String
Name for response event
Remote Action
NetworkRemoteAction
Remote action component
Sender
NetworkIdentity
Who sent this remote action

Target RPC Trigger Unit

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

Parameters

Connection
Type
Description
Event Target
GameObject
Where is the EventName event
Parameter
object(System)
Incomming data
EventName
String
Name for response event
Remote Action
NetworkRemoteAction
Remote action component
Sender
NetworkIdentity
Who sent this remote action

Get Remote Action Unit

Description

Get the NetworkRemoteAction from the target object.

Return

NetworkRemoteAction

Parameters

Connection
Description
Target
Where is the NetworkRemoteAction component.

Synchronizer Units

Number Synchronizer Unit

Description

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

Parameters

Connection
Type
Description
Target
GameObject
Where is the Synchronizer event
SyncValue
Int,Float
Incomming data
Write
Bool
If true, this unit will be send data to all clients, otherwise is read from remote client.
Sender
NetworkIdentity
Who sent this remote action

Quaternion Synchronizer Unit

Description

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

Parameters

Connection
Type
Description
Target
GameObject
Where is the Synchronizer event
SyncValue
Quaternion
Incomming data
Write
Bool
If true, this unit will be send data to all clients, otherwise is read from remote client.
Sender
NetworkIdentity
Who sent this remote action

String Synchronizer Unit

Description

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

Parameters

Connection
Type
Description
Target
GameObject
Where is the Synchronizer event
SyncValue
String
Incomming data
Write
Bool
If true, this unit will be send data to all clients, otherwise is read from remote client.
Sender
NetworkIdentity
Who sent this remote action

Vector3 Synchronizer Unit

Description

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

Parameters

Connection
Type
Description
Target
GameObject
Where is the Synchronizer event
SyncValue
Vector3
Incomming data
Write
Bool
If true, this unit will be send data to all clients, otherwise is read from remote client.
Sender
NetworkIdentity
Who sent this remote action

Utility Units

Assign ClientAuthority Unit

Description

This can be done by calling AssignClientAuthority on the object you want to give authority to.

Parameters

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

Create TransformData Unit

Description

Create a transform data(Position,Rotation,Scale) and send to other clients.

Description

TransformData

Parameters

Connection
Type
Description
Position
Vector3
The position of game object
Rotation
Quaternion
The rotation of game object
Scale
Vector3
The scale of game object

Get LocalIP Unit

Description

Get current device IP Address(IPV4).

Return

String IP Address. e.g. 192.168.0.100

Get LocalPlayer Unit

Access the local player game object.

Return

GameObject

Get NetworkConnection Unit

Description

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

Get NetworkPrefab Unit

Description

Get the network prefab from registration list.

Return

Network GameObject

Parameters

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

Has Authority Unit

Description

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

Return

True or False.

Parameters

Connection
Type
Description
Target
NetworkIdentity
Need to check of authority network game object

Is Server Unit

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.

Parameters

Connection
Type
Description
Target
NetworkIdentity
Need to check of server side's network game object

Network Animator Trigger Unit

Description

Sync the Animator.Trigger method. Because NetworkAnimator component is not sync Trigger state.

Parameters

Connection
Type
Description
Trigger Name
String
Need to trigger state condition name
Trigger Type
Enum
Set trigger or reset trigger of condition
Animator
Animator
The animator component

NetworkObject Destroy Unit

Description

Destroy network gameobject from network.

Parameters

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

Register Prefab Unit

Description

Register the prefab to spawning system.

Parameters

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

Spawn Player Unit

Description

Create the local player on the network.

Parameters

Connection
Type
Description
Network GameObject
GameObject
The player character

Spawn Prefab Unit

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
Network GameObject
GameObject
The network gameobject want to spawn

Spawn Sync Unit

Description

Synchronize to other clients when game object is instanced.

Parameters

Connection
Type
Description
Network GameObject
GameObject
Need to synced gameobject
Last modified 1mo ago