Getting Players
These nodes are useful for getting an individual Player, a group of them, or all of them.
Networking.get LocalPlayer
VRCPlayerApi
Please note that this function is a member of the Networking class, but it is being included here.
The local player is the Player that this Udon script is currently running on-- alternately, the local player is you. It's very important to know yourself!
GetPlayerCount
int
Gets the actual number of Players in the instance when it is called.
GetPlayers
VRCPlayerApi[]
This is how you get all the Players in your world so you can go through them in a For Loop and apply settings, make changes, look for a particular name, etc. To use it, you first need to create a VRCPlayerApi Array.
- Udon Graph
- UdonSharp
var players = new VRCPlayerApi[VRCPlayerApi.GetPlayerCount()];
VRCPlayerApi.GetPlayers(players);
Above, you can see the bare minimum for a working call to GetPlayers. A better approach would be to construct VRCPlayerApi[] as a variable so you can reuse it.
GetPlayerById
int
Get a VRCPlayerApi object for the given player Id if it exists.
get playerId
int
Get the cached PlayerId, calls GetPlayerId if it hasn't been cached yet.