Skip to content

New Synchronization

Tamira edited this page Jan 15, 2019 · 1 revision

New Synchronization

DOCUMENTATION IN PROGRESS --------- DOCUMENTATION IN PROGRESS --------- DOCUMENTATION IN PROGRESS

  • using Unity's RPC and Command methods for synchronizing data

Used Classes

DataDistributor

  • Using a dictionary to store tags of attributes and reference to the gameObjects' instances.
  • Remote procedure calls (RPCs) are used to send messages from the server to clients.
  • RPCs can only send primitive datatypes (and also Vector3 and Quaternion) via the network.

Usable implemented RPCs are:

public void RpcSendString(string key, string value); public void RpcSendChar(string key, char value); public void RpcSendInt(string key, int value); public void RpcSendFloat(string key, float value); public void RpcSendDouble(string key, double value); public void RpcSendVector3(string key, Vector3 value); public void RpcSendQuaternion(string key, Quaternion value);

InstantiateNode

  • Inherits from NetworkBehavior
  • Starts Clients/Server
  • Spawns prefabs which need to be synchronized.

MyNetworkTransform

  • Synchronizes rotation and position.

SpawnableObject

  • The class which calls RPC methods in the game loop ("Game Logic)"
  • registers synchronizable attributes in the dictionary of DataDistributor

public override void SetValue(string key, T value) //(with T as any primitive datatype, as well as Vector3 and Quaternion) if(key.Equals(someTag)) //do something

Usage

Clone this wiki locally