Skip to content

Unity SDK

Networked objects

SyncVerseView, spawning and destroying, ownership, and syncing your own components.

SyncVerseView

Every networked object has a SyncVerseView. It gives the object an id that is the same on every client, an owner, and a send loop. Check view.IsMine before acting on input.

SettingDefaultWhat it does
SyncUnreliableOnChangeOff, Unreliable, UnreliableOnChange or Reliable
SendRate30State sends per second, 1–60
OwnershipTransferFixedFixed, Takeover or Request

Unreliable means the server drops state for a receiver that is falling behind rather than queueing it; ordering is still preserved. OnChange skips a send when nothing changed, which keeps idle objects silent.

Spawn and destroy

C#
// Prefab at Resources/Player with a SyncVerseView. The local player owns the new object.
GameObject me = room.Instantiate ("Player", spawn.position, spawn.rotation);

// Optional: let anyone take it over, and pass data every client receives.
room.Instantiate ("Ball", pos, Quaternion.identity, OwnershipMode.Takeover, new byte[] { 3 });

room.Destroy (me);   // owner or master client

Remote copies are created inactive, set up, then activated, so Awake and Start already see the view's owner and InstantiationData. When a player leaves, the objects they own are destroyed on every client.

Scene objects

A SyncVerseView placed in a scene gets an id in the editor automatically. Scene objects always belong to the master client and cannot be destroyed over the network.

Ownership

C#
// Fixed: only the owner (or the master client) can hand it over.
view.TransferOwnership (otherPlayer);

// Takeover: anyone can take it.
view.RequestOwnership ();

// Request: the owner decides.
room.OnOwnershipRequested += (view, requester) => {
    if (view.IsMine) view.TransferOwnership (requester);
};

Everyone gets OnOwnershipChanged (and view.OnOwnerChanged) when an owner changes.

Built-in sync components

ComponentSyncs
SyncTransformPosition, rotation, optional scale; lerps toward the latest state and snaps past a teleport distance
SyncTransformAdvancedSame fields with snapshot interpolation on a shared server clock and an adaptive delay
SyncAnimatorAnimator parameters and layer weights
SyncRigidbodyVelocity and angular velocity

Sync your own state

Implement ISyncVerseObservable on any component of the object. The view calls it at its send rate on the owner and on every receive elsewhere.

C#
public class Health : MonoBehaviour, ISyncVerseObservable {
    public int Hp = 100;

    // On the owner the stream writes; on everyone else it reads. Same order both ways.
    public void OnSerializeView (SyncVerseStream stream, SyncVerseMessageInfo info) {
        stream.Serialize (ref Hp);
    }
}

For one-off actions (a shot, a chat line) use RPCs instead.