VRC SDK
This project aims to completely document the VRChat Unity SDK
Loading...
Searching...
No Matches
VRC.SDKBase.Networking Class Reference

Networking is a class that provides a set of static methods relating to the networking of UdonBehaviours. More...

Inheritance diagram for VRC.SDKBase.Networking:
Collaboration diagram for VRC.SDKBase.Networking:

Public Types

enum  SyncType : Enum
 The different sync types available for entire U# objects. Setting this in code will remove the inspector header that allows you to set the sync type in-editor. More...
 

Static Public Member Functions

static bool IsOwner (VRCPlayerApi player, GameObject obj)
 Tells you whether a Player is the Owner of a given GameObject, important for Sync. More...
 
static bool IsOwner (GameObject obj)
 Tells you whether the local Player is the Owner of a given GameObject, important for Sync. More...
 
static VRCPlayerApi GetOwner (GameObject obj)
 Returns the VRC.SDKBase.VRCPlayerApi object of the owner of a given GameObject. More...
 
static void SetOwner (VRCPlayerApi player, GameObject obj)
 Sets the owner of a given GameObject to a given player. More...
 
static bool IsObjectReady (GameObject obj)
 Returns whether a given GameObject is ready for use. More...
 
static GameObject Instantiate (VRC_EventHandler.VrcBroadcastType broadcast, string prefabPathOrDynamicPrefabName, Vector3 position, Quaternion rotation)
 
static void RPC (RPC.Destination targetClients, GameObject targetObject, string methodName, params object[] parameters)
 
static void RPC (VRCPlayerApi targetPlayer, GameObject targetObject, string methodName, params object[] parameters)
 
static byte[] EncodeParameters (params object[] parameters)
 
static object[] DecodeParameters (byte[] encodedData)
 
static void Destroy (GameObject obj)
 
static string GetUniqueName (GameObject obj)
 Returns a unique name for a given GameObject. More...
 
static bool GoToRoom (string roomID)
 
static DateTime GetNetworkDateTime ()
 Returns the current network time as a System.DateTime object. More...
 
static double GetServerTimeInSeconds ()
 Returns the current server time in seconds. More...
 
static int GetServerTimeInMilliseconds ()
 Returns the current server time in milliseconds. More...
 
static double CalculateServerDeltaTime (double timeInSeconds, double previousTimeInSeconds)
 Calculates the difference between two server time stamps as returned by VRC.SDKBase.Networking.GetServerTimeInSeconds. More...
 
static Coroutine SafeStartCoroutine (IEnumerator target)
 
static VRC_EventDispatcher GetEventDispatcher ()
 
static float SimulationTime (GameObject target)
 returns the current simulation time of a object with networking components. Simulation time is a timestamp that refers to how far back in time an object is simulated. More...
 
static float SimulationTime (VRCPlayerApi target)
 returns the current simulation time of a player. Simulation time is a timestamp that refers to how far back in time an object is simulated. More...
 
static GameObject[] GetPlayerObjects (VRCPlayerApi target)
 
static Component FindComponentInPlayerObjects (VRCPlayerApi target, Component referenceComponent)
 

Properties

static VRC_EventHandler SceneEventHandler [get]
 
static bool IsNetworkSettled [get]
 returns true once all the data in the instance has been deserialized and applied, and it's ready for use. More...
 
static bool IsMaster [get]
 Tells you whether the local Player is the instance master. More...
 
static bool IsClogged [get]
 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. More...
 
static bool IsInstanceOwner [get]
 This Property has known issues, check the listed cannys for more information, as its behaviour may not work as documented/expected.

if the local Player is the one who created the instance.

Canny PostDescription
Canny Post #1
This property is currently broken, and will always return true! use VRC.SDKBase.VRCPlayerApi.isInstanceOwner instead. More...
 
static VRCPlayerApi LocalPlayer [get]
 returns the VRC.SDKBase.VRCPlayerApi object of the local player. More...
 
static VRCPlayerApi Master [get]
 
static VRCPlayerApi InstanceOwner [get]
 

Detailed Description

Networking is a class that provides a set of static methods relating to the networking of UdonBehaviours.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10341 of file VRCSDKBase.cs.

Member Enumeration Documentation

◆ SyncType

The different sync types available for entire U# objects. Setting this in code will remove the inspector header that allows you to set the sync type in-editor.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10350 of file VRCSDKBase.cs.

Member Function Documentation

◆ CalculateServerDeltaTime()

static double VRC.SDKBase.Networking.CalculateServerDeltaTime ( double  timeInSeconds,
double  previousTimeInSeconds 
)
static

Calculates the difference between two server time stamps as returned by VRC.SDKBase.Networking.GetServerTimeInSeconds.

Parameters
timeInSecondsThe first server time stamp.
previousTimeInSecondsThe second server time stamp.
Returns
The difference between the two server time stamps in seconds.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10812 of file VRCSDKBase.cs.

◆ DecodeParameters()

static object[] VRC.SDKBase.Networking.DecodeParameters ( byte[]  encodedData)
static

Definition at line 10705 of file VRCSDKBase.cs.

◆ Destroy()

static void VRC.SDKBase.Networking.Destroy ( GameObject  obj)
static

Definition at line 10714 of file VRCSDKBase.cs.

◆ EncodeParameters()

static byte[] VRC.SDKBase.Networking.EncodeParameters ( params object[]  parameters)
static

Definition at line 10696 of file VRCSDKBase.cs.

◆ FindComponentInPlayerObjects()

static Component VRC.SDKBase.Networking.FindComponentInPlayerObjects ( VRCPlayerApi  target,
Component  referenceComponent 
)
static

Definition at line 10912 of file VRCSDKBase.cs.

Here is the caller graph for this function:

◆ GetEventDispatcher()

static VRC_EventDispatcher VRC.SDKBase.Networking.GetEventDispatcher ( )
static

Definition at line 10830 of file VRCSDKBase.cs.

◆ GetNetworkDateTime()

static DateTime VRC.SDKBase.Networking.GetNetworkDateTime ( )
static

Returns the current network time as a System.DateTime object.

Returns
The current network time as a System.DateTime object.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10755 of file VRCSDKBase.cs.

◆ GetOwner()

static VRCPlayerApi VRC.SDKBase.Networking.GetOwner ( GameObject  obj)
static

Returns the VRC.SDKBase.VRCPlayerApi object of the owner of a given GameObject.

Parameters
objThe GameObject to check ownership of.
Returns
The VRC.SDKBase.VRCPlayerApi object of the owner of the GameObject.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10621 of file VRCSDKBase.cs.

◆ GetPlayerObjects()

static GameObject[] VRC.SDKBase.Networking.GetPlayerObjects ( VRCPlayerApi  target)
static

Definition at line 10903 of file VRCSDKBase.cs.

Here is the caller graph for this function:

◆ GetServerTimeInMilliseconds()

static int VRC.SDKBase.Networking.GetServerTimeInMilliseconds ( )
static

Returns the current server time in milliseconds.

Returns
The current server time in milliseconds.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10791 of file VRCSDKBase.cs.

◆ GetServerTimeInSeconds()

static double VRC.SDKBase.Networking.GetServerTimeInSeconds ( )
static

Returns the current server time in seconds.

Returns
The current server time in seconds.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10774 of file VRCSDKBase.cs.

◆ GetUniqueName()

static string VRC.SDKBase.Networking.GetUniqueName ( GameObject  obj)
static

Returns a unique name for a given GameObject.

Uses

obj.GetInstanceID().ToString();

in clientsim, unsure if it's the same in the actual client
Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Parameters
objThe GameObject to get the unique name of.
Returns
A unique name for the GameObject. This will be a integer (in string form) that is unique to that object. This is NOT the same as string.GetHashCode on the name of the object.

Definition at line 10733 of file VRCSDKBase.cs.

◆ GoToRoom()

static bool VRC.SDKBase.Networking.GoToRoom ( string  roomID)
static

Definition at line 10742 of file VRCSDKBase.cs.

◆ Instantiate()

static GameObject VRC.SDKBase.Networking.Instantiate ( VRC_EventHandler.VrcBroadcastType  broadcast,
string  prefabPathOrDynamicPrefabName,
Vector3  position,
Quaternion  rotation 
)
static

Definition at line 10669 of file VRCSDKBase.cs.

◆ IsObjectReady()

static bool VRC.SDKBase.Networking.IsObjectReady ( GameObject  obj)
static

Returns whether a given GameObject is ready for use.

Parameters
objThe GameObject to check.
Returns
True if the GameObject is ready for use, false if it is not.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10660 of file VRCSDKBase.cs.

◆ IsOwner() [1/2]

static bool VRC.SDKBase.Networking.IsOwner ( GameObject  obj)
static

Tells you whether the local Player is the Owner of a given GameObject, important for Sync.

Parameters
objThe GameObject to check ownership of.
Returns
True if the player is the owner of the GameObject, false if they are not.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10603 of file VRCSDKBase.cs.

◆ IsOwner() [2/2]

static bool VRC.SDKBase.Networking.IsOwner ( VRCPlayerApi  player,
GameObject  obj 
)
static

Tells you whether a Player is the Owner of a given GameObject, important for Sync.

Parameters
playerThe player to check ownership of.
objThe GameObject to check ownership of.
Returns
True if the player is the owner of the GameObject, false if they are not.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10582 of file VRCSDKBase.cs.

Here is the caller graph for this function:

◆ RPC() [1/2]

static void VRC.SDKBase.Networking.RPC ( RPC.Destination  targetClients,
GameObject  targetObject,
string  methodName,
params object[]  parameters 
)
static

Definition at line 10680 of file VRCSDKBase.cs.

Here is the caller graph for this function:

◆ RPC() [2/2]

static void VRC.SDKBase.Networking.RPC ( VRCPlayerApi  targetPlayer,
GameObject  targetObject,
string  methodName,
params object[]  parameters 
)
static

Definition at line 10688 of file VRCSDKBase.cs.

◆ SafeStartCoroutine()

static Coroutine VRC.SDKBase.Networking.SafeStartCoroutine ( IEnumerator  target)
static

Definition at line 10821 of file VRCSDKBase.cs.

Here is the caller graph for this function:

◆ SetOwner()

static void VRC.SDKBase.Networking.SetOwner ( VRCPlayerApi  player,
GameObject  obj 
)
static

Sets the owner of a given GameObject to a given player.

Parameters
playerThe player to set as the owner.
objThe GameObject to check ownership of.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10641 of file VRCSDKBase.cs.

◆ SimulationTime() [1/2]

static float VRC.SDKBase.Networking.SimulationTime ( GameObject  target)
static

returns the current simulation time of a object with networking components. Simulation time is a timestamp that refers to how far back in time an object is simulated.

This value is used internally for VRCObjectSync and players, but can be used in Udon scripts as well. For example, if your Time.realtimeSinceStartup is 45 and the SimulationTime of an object is 44.5, then VRChat believes 500ms of delay is necessary to smoothly replicate the object at that moment. You can use that number to learn some information about what VRCObjectSync is doing, or to create your own system similar to VRCObjectSync. For example, if you do Time.realTimeSinceStartup - SimulationTime(player) then that will tell you exactly how much latency that player has at that moment. Simulation time is frequently adjusted depending on network conditions, including many factors such as latency, reliability, and frequency of the packets being received. The goal of this adjustment is to be as close to real-time as possible to reduce latency, but to leave enough room to prevent hitching. There are a variety of factors that can cause hitching, but one example can be running out of received packets from the owner.
Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Parameters
objThe GameObject to get the simulation time of.
Returns
The current simulation time of the object. This MAY be UnityEngine.Time.time

Definition at line 10862 of file VRCSDKBase.cs.

◆ SimulationTime() [2/2]

static float VRC.SDKBase.Networking.SimulationTime ( VRCPlayerApi  target)
static

returns the current simulation time of a player. Simulation time is a timestamp that refers to how far back in time an object is simulated.

This value is used internally for VRCObjectSync and players, but can be used in Udon scripts as well. For example, if your Time.realtimeSinceStartup is 45 and the SimulationTime of an object is 44.5, then VRChat believes 500ms of delay is necessary to smoothly replicate the object at that moment. You can use that number to learn some information about what VRCObjectSync is doing, or to create your own system similar to VRCObjectSync. For example, if you do Time.realTimeSinceStartup - SimulationTime(player) then that will tell you exactly how much latency that player has at that moment. Simulation time is frequently adjusted depending on network conditions, including many factors such as latency, reliability, and frequency of the packets being received. The goal of this adjustment is to be as close to real-time as possible to reduce latency, but to leave enough room to prevent hitching. There are a variety of factors that can cause hitching, but one example can be running out of received packets from the owner.
Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Parameters
targetThe player to get the simulation time of.
Returns
The current simulation time of the object. This MAY be UnityEngine.Time.time

Definition at line 10894 of file VRCSDKBase.cs.

Property Documentation

◆ InstanceOwner

VRCPlayerApi VRC.SDKBase.Networking.InstanceOwner
staticget

Definition at line 10556 of file VRCSDKBase.cs.

◆ IsClogged

bool VRC.SDKBase.Networking.IsClogged
staticget

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.


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10493 of file VRCSDKBase.cs.

◆ IsInstanceOwner

bool VRC.SDKBase.Networking.IsInstanceOwner
staticget

This Property has known issues, check the listed cannys for more information, as its behaviour may not work as documented/expected.

if the local Player is the one who created the instance.

Canny PostDescription
Canny Post #1
This property is currently broken, and will always return true! use VRC.SDKBase.VRCPlayerApi.isInstanceOwner instead.

Will be False when in Build & Test and Unity Playmode.
Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10516 of file VRCSDKBase.cs.

◆ IsMaster

bool VRC.SDKBase.Networking.IsMaster
staticget

Tells you whether the local Player is the instance master.

This is the player who either created the instance, or the one who inherited Master status when the last Master left.
Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10475 of file VRCSDKBase.cs.

◆ IsNetworkSettled

bool VRC.SDKBase.Networking.IsNetworkSettled
staticget

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


Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10458 of file VRCSDKBase.cs.

◆ LocalPlayer

VRCPlayerApi VRC.SDKBase.Networking.LocalPlayer
staticget

returns the VRC.SDKBase.VRCPlayerApi object of the local player.

Will be null in the editor, unless using a client emulator - use VRC.SDKBase.VRCPlayerApi.IsValid to easily branch your logic on this.
Check the VRChat documentation for more information.
Docs generated by the VRChat SDK Documentation Project.

Definition at line 10532 of file VRCSDKBase.cs.

◆ Master

VRCPlayerApi VRC.SDKBase.Networking.Master
staticget

Definition at line 10544 of file VRCSDKBase.cs.

◆ SceneEventHandler

VRC_EventHandler VRC.SDKBase.Networking.SceneEventHandler
staticget

Definition at line 10440 of file VRCSDKBase.cs.


The documentation for this class was generated from the following file: