The VRChat Documentation Hub

Welcome to the VRChat Documentation hub. You'll find comprehensive guides and documentation to help you start working with VRChat as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Network Components

This doc covers Networking Components, Properties and Events you can use in your Udon Programs.

Networking Properties

Special properties you can get from Networking:

IsClogged - returns true if there is too much data trying to get out. You can use this to hold off some operations or adjust your logic.

IsInstanceOwner - returns true if the Local Player is the one who created the instance. False when in Build & Test and Unity Playmode.

IsMaster - returns true if the Local Player is the 'Master' - either the first person who entered the instance or the person automatically designated as Master when the last Master left. Old logic, not recommended for use. IsOwner or IsInstanceOwner are better.

IsNetworkSettled - returns true once all the data in the instance has been deserialized and applied, and it's ready for use.

LocalPlayer - returns the VRC Player API object of the local player. Will be null in the editor - use Utilities.IsValid to easily branch your logic on this.

Networking Events

These are the events available as part of the Networking system to control how your data is synced.

OnPreSerialization:

This event triggers just before serialized data will be sent out, it's a good place to set synced variables that you want to be updated for other players.

OnDeserialization:

This event triggers when sync data has been transformed from bytes back into usable variables. It does not tell you which data has been updated, but serves as a jumping-off point to either update everything that watches synced variables, or a place to check new data against old data and make specific updates.

OnPostSerialization:

This event triggers just after an attempt was made to send serialized data. It returns a SerializationResult struct with a 'success' bool and 'byteCount' int with the number of bytes sent.

OnSpawn:

This event is deprecated - use the typical OnEnabled event if you want to do something when an object is 'Spawned' from the pool.

OnOwnershipRequest:

This event is triggered when someone has requested to take ownership. It includes the Player Objects for the Requester and the Requested Owner. To approve or deny the change, set a boolean value into a "Set Return Value" node. This logic runs locally on both the requester and the owner, so be aware that disagreements in logic between the two will cause a desync. This is most likely to be expressed by the ownership transfer being unexpectedly rejected by the owner.

OnOwnershipTransferred:

This event is triggered for everyone in the instance when an objects ownership is changed, and includes the Player Object for the new owner.

VRC Object Sync

This component will automatically sync the Transform (position, rotation scale) and Rigidbody (physics) of the object you put it on. It has a few special methods and properties you can access:

FlagDiscontinuity

Trigger this when you want to teleport the object - the changes you make this frame will be applied without smoothing.

Set/Get Gravity

Changes the gravity state, usually handled by the Rigidbody of the object but controlled here for sync purposes.

Set/Get Kinematic:

Changes the kinematic state, usually handled by the Rigidbody of the object but controlled here for sync purposes. When the kinematic state is on, this Rigidbody ignores forces, collisions and joints.

Respawn:

Teleports this object back to its starting Position and Rotation, and removes its Velocities.
Specifically, it sets DiscontinuityHint to true to make the following changes instant instead of smooth. Then it:

  • sets transform.position to initial position
  • sets transform.rotation to initial rotation

If the object has a rigidbody:

  • sets the rigidbody.velocity to Vector3.zero
  • sets the rigidbody.angularVelocity Vector3.zero
  • sets the rigidbody.position to initial position
  • sets the rigidbody.rotation to initial rotation

VRC Object Pool

VRC Object Pool provides a lightweight method of managing an array of game objects. The pool will manage and synchronize the active state of each object it holds.

To make an object active, the Owner of the pool triggers the TryToSpawn node, which will return the object that was made active, or a null object if none are available. Objects may be returned to the pool by the pool's owner, and automatically disabled, via the Return node.

Late joiners will have the objects automatically made active or inactive where appropriate.

Updated 3 months ago


Network Components


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.