Skip to main content

Players

A StageTimePlayer is one player in the room. You get players from Networking.LocalPlayer, from player events (OnPlayerJoined, OnSeatEntered, …) and from the lookups below.

API
displayNameThe player's name
playerIdTheir id in this room (stable while they stay)
isLocalThe player on this device
isMasterThe room's master
IsValid()Still in the room (also Utilities.IsValid(player))
IsUserInVR()In VR (false on desktop and phones)
GetPosition(), GetRotation()Where they stand and face
GetHeadPosition(), GetHeadRotation()Their head
TeleportTo(position, rotation)Move the local player
IsOwner(gameObject)They own the object
StageTimePlayer.GetPlayerCount()Players in the room
StageTimePlayer.GetPlayers(array)Fills an array with them
StageTimePlayer.GetPlayerById(id)A player by id, or null
public void ListPlayers()
{
StageTimePlayer[] players = new StageTimePlayer[StageTimePlayer.GetPlayerCount()];
StageTimePlayer.GetPlayers(players);
string text = "";
foreach (StageTimePlayer p in players)
text += $"[{p.playerId}] {p.displayName}{(p.isLocal ? " (you)" : "")}\n";
label.text = text;
}
note

displayName can briefly be "Player N" right after someone joins, while their profile loads. OnPlayerJoined waits for the name (up to a few seconds), so names read there are normally real ones.