category: Plugins

the replicator plugin use the stormancer behaviours to synchronize data though all your clients.

How to use the replicator

The replicator is based on the stormancer behaviours for unity3D.

Once you enabled the behaviours on your project, put the replicatorBehaviour on the same GameObject you put the RemoteScene you want to replicate (if don't want the scene to be destroyed on unload, you should keep the replicator too)

enter image description here

RemoteScene is the remoteScene you want the replicator to plug to.

Use Debug Ghost if you want your local objects to be also registered as network objects. Useful to run tests without the need of a second client.

The prefab list is the list of object bases you are going to use as replicants.

Local object to sync are the objects you want to be replicated on distant peers on game scene start up.

NetWork Identity

Every replicated object needs to have a component NetworkIdentity. If an object doesn't have it, it won't be replicated.

enter image description here

Is master shows whether your current client owns the object or not.

If your object is owned by your client, you have to tell what prefab (located in the replicatorbehaviour) it comes from. PrefabId will be broadcasted to every peers: they will use it to show you.

Id and MasterId are replicator specific info. they are shown to help you debug you program.

SyncBehaviours

You can now implement your own custom syncBehaviours.

public abstract class SyncBehaviourBase : MonoBehaviour
{
    ...

    public abstract void SendChanges(Stream stream);
    public abstract void ApplyChanges(Stream stream);
}

SendChanges will be called on the objects you own by the replicator behaviours each timeBetweenUpdate. Write in the stream received every changes you want to be broadcasted to every peers.

ApplyCHanges will be called on every object you don't own immediatly after receiving an update from their owner.

Exemple: Interpolator plugin

The interpolator plugin is a bunch a syncBehaviours made to synchronize, interpolate and extrapolate position of your object though the network.

It is made of two scripts:

The LocalObject will be put on your owned objects to sent their position. Put it on everyobject you own and have a networkIdentity.

enter image description here

The Interpolator plugin is to be put on every prefab you want their positions to be synchronized.

enter image description here

Be sure to have to same TimeBetWeenUpdate on your different scripts: the interpolator uses this time to interpolate the positions.

Activate Bezier if you want to smooth the tragectory of the synched objects. Activate Extrapolate if you want to object to continue moving even if no position updates were received.

We recommand to keep the reliability as UNRELIABLE as position updates are often fired. Reliable protocol is bandwidth consuming and should not be used when dealing with position update.