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 | |
|---|---|
displayName | The player's name |
playerId | Their id in this room (stable while they stay) |
isLocal | The player on this device |
isMaster | The room's master (reliable for the local player only) |
isRoomHost, isModerator, isInstanceOwner | Roles |
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;
}
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.
Roles
Roles come from StageTime and are known for every player, so any device can check them:
| Role | Who |
|---|---|
isInstanceOwner | The player who created this room |
isRoomHost | The room's creator, an event host, or a StageTime admin |
isModerator | StageTime moderators and admins |
public Button adminButton;
void Start()
{
StageTimePlayer me = Networking.LocalPlayer;
adminButton.interactable = me.isRoomHost || me.isModerator;
}
Use them to show admin controls. An ST Queue uses them for removing other players' entries and clearing, and an ST Video Player can be limited to them.
For your own cosmetic roles (VIPs, staff badges), download a list of display names with an
ST String Downloader and compare displayName with it. These are for show
only: anyone can choose a name.