ParelVRDocs
Player site

Scripting / Reference

Networking

Types in the ParelVR.Volt.Networking namespace.

VoltNetworkTarget#

ParelVR.Volt.Networking.VoltNetworkTarget enum

Who receives a network event.

Value Meaning
All (0) Everyone in the instance, the sender included.
Others (1) Everyone except the sender.
Owner (2) The player who owns the object.
Master (3) The instance master.
Authority (4) The player with authority over the object: its owner, or the master when it has none.
Local (5) Only this client; nothing is sent.

VoltNetworking#

ParelVR.Volt.Networking.VoltNetworking static

The state of the connection to other players, and ownership of world objects.

VoltNetworking properties#

static float InterestDistance { get; set; }

Beyond this distance in metres from every other player, synced objects and scripts send their state four times less often. 0, the default, turns it off.

static bool IsConnected { get; }

True while the client is connected to the instance.

static bool IsMaster { get; }

True when the local player is the instance master.

static bool IsStateReady { get; }

True once this client has received the current state of every synced object.

static VoltPlayer LocalPlayer { get; }

The player on this client.

static VoltPlayer Master { get; }

The instance master.

static int Ping { get; }

Round trip time to the instance server in milliseconds.

static int ServerTimeMs { get; }

A clock in milliseconds that is the same for every player in the instance. Use it to time shared events.

VoltNetworking methods#

static VoltPlayer GetOwner(VoltGameObject target)

The player who owns the object. The master for an object nobody has claimed.

static bool IsOwner(VoltGameObject target)

True when the local player owns the object.

static bool IsOwner(VoltPlayer player, VoltGameObject target)

True when the player owns the object.

static void SetOwner(VoltPlayer player, VoltGameObject target)

Gives the object to a player. Only its owner or the master can do this, and the owner can refuse a request.

VoltObjectPool#

ParelVR.Volt.Networking.VoltObjectPool component extends VoltSceneComponent

A fixed set of scene objects that the master turns on (spawns) and off (returns) for everyone. Late joiners see the same objects on. Add a VoltObjectSync to the objects to sync where they are too.

VoltObjectPool properties#

int ActiveCount { get; }

How many of them are spawned.

int Count { get; }

How many objects the pool has.

VoltObjectPool methods#

VoltGameObject GetObject(int index)

An object of the pool by position, spawned or not.

void Return(VoltGameObject target)

Turns an object of the pool off for everyone. Master only.

VoltGameObject TryToSpawn()

Turns on the first object that is off, for everyone, and returns it. Null when all are on. Master only.

VoltObjectSync#

ParelVR.Volt.Networking.VoltObjectSync component extends VoltSceneComponent

Keeps the position and rotation of an object the same for every player. The owner's copy decides; the others follow it smoothly. Add it to anything players can move: pickups, physics props, doors on hinges.

VoltObjectSync properties#

bool IsOwner { get; }

True when the local player owns the object.

VoltPlayer Owner { get; }

The player whose copy of the object decides where it is.

VoltObjectSync methods#

void Respawn()

Puts the object back where it was when the world loaded, for everyone. Owner only.

void SetGravity(bool useGravity)

Turns gravity on or off for everyone. Owner only.

void SetKinematic(bool isKinematic)

Makes the body kinematic or dynamic for everyone. Owner only.

void TeleportTo(Vector3 position, Quaternion rotation)

Moves the object at once for everyone, without easing. Owner only.