Skip to content

Seats, joining and waiting

A seat is a player’s place in a hosted game. This page covers MultiplayerSession, the static class your game uses to start a session, read its seats and, on the host, to kick, ban, assign and claim. The file is MultiplayerSession.cs.

Seat 0 is the host’s own player. A remote player gets a number from 1 up. A number is never reused within a host’s run, also across a save and a load (SeatTable.cs, line 204).

A seat plays one character. When the player disconnects, the seat stays and the game plays that character, so the seat is away. The player comes back to the same seat with the key the host gave. Away seats count against the limit: once every seat was given, new players are refused as full until the host kicks one (SeatTable.cs, line 149). The key is kept in memory on the player’s machine. A restarted game joins as a new player unless the game keeps MultiplayerSession.PlayerKey or uses SeatKeyStore.

StartHost(HostSettings) and StartClient(ClientSettings) return false when the session does not start: a session already runs, there is no Intrigue Manager, the settings have no transport, or the transport does not start. Stop(string reason = null) ends this machine’s session. With NGO you rarely call them yourself, because the Netcode Session component does, as the Quick start shows.

Member What it gives
SessionStatus State None, Hosting, Connecting, Loading, Joining or Playing.
bool IsHost, bool IsClient What this machine is doing.
IReadOnlyList<SeatInfo> Seats, int GetSeats(List<SeatInfo> into) The seats. On a client, the seats the host told it of.
int Seat The seat this client was given (0 for none).
bool WaitingForActor Client: true while the seat waits without a character.
event Action<SeatInfo> onPlayerJoined, onPlayerLeft Host only. A seat connected, new or back, or a connected player left.
event Action<SessionEndInfo> onSessionEnded, event Action<SessionStatus> onStateChanged The session ended, or State changed. Use the second for a loading screen.

A SeatInfo has Seat, ActorId, HasActor, Connected and Actor.

The bool calls return false on a client and for an unknown seat. The ClaimResult calls return a refusal (NotHost on a client). ClearBans returns nothing and works with or without a session.

Signature What it does
Kick(int seat, string reason = null) Removes the seat and its player. The key no longer opens it. The same player may join again as a new player while the host takes new players (Accepting).
Ban(int seat, string reason = null, bool byAddress = true) Removes the seat and refuses its key from now on. With byAddress, connections from the player’s last address are closed too. Bans are not saved.
ClearBans() Lifts every ban. Bans last for the whole run of the game until you call it.
FreeAwaySeat(int seat, string reason = null) Frees the character of an away seat, only while its player is still away.
Assign(int seat, Actor actor) The player of the seat plays the actor from now on. False for an actor someone else plays.
ClaimResult Claim(int seat, Actor actor) Gives a character to a seat that waits without one.
ClaimResult ClaimAll(IReadOnlyList<SeatClaim> claims) The same for several seats, all or nothing. CheckClaims runs the checks without giving anything.
ClaimResult HandAwaySeat(int awaySeat, int toSeat) Hands an away seat’s character to a connected player who plays none yet.
bool ReleaseAway(int seat), bool WaitsFor(int seat) End, or ask about, a wait for an away player that a load brought back. See Saving in multiplayer.

An address ban shuts out everyone behind that address, so pass false to ban the key only. The Security notes cover identities.

Players who pick their character after joining

Section titled “Players who pick their character after joining”

By default a new player must name a character in ClientSettings.WantedActorId, and a join without one is refused. Set HostSettings.AllowJoinWithoutActor and a new player may join with none. That player waits in a seat of their own, for example in your lobby while everybody picks.

A waiting seat plays nobody. Its machine sees only the public world and gets no dialogue, sound, music or signal, it may send the host only its language and your own messages, and no other player is told of it, while IM.Player is empty there and WaitingForActor is true.

The host gives the seat a character with Claim, or all seats at once with ClaimAll. All or nothing. If one claim is refused, no seat gets a character (one exception: when your own listener of a seat change kicks a seat or takes the actor meanwhile, that claim alone is refused Changed), and ClaimResult.Text says why in words you can show. ClaimResult.Refusal is a ClaimRefusal, such as ActorTaken, NotAllowed or WorldNotReady. A claim is checked like a join: the character exists, nobody plays it, JoinActors and PlayableActors allow it, and your SeatPolicy.AllowJoin agrees.

Example, not compiled. It uses the signatures above.

var result = MultiplayerSession.Claim(seat, actor);
if (!result.Ok) Debug.Log(result.Text);

A waiting seat is not saved. A load, a new game or a scene change ends it. A waiting player who leaves keeps the seat for UnseatedRejoinSeconds (10), then it is removed. UnseatedTimeoutSeconds (default 0, no limit) removes a seat that waited that long.

HostSettings.JoinActors decides: Free (the default; it withholds for good the schemes already running in which another player takes part, SessionSettings.cs, lines 199 to 203, and PlayableActors also limits it when it lists any), ListedOnly (only the characters in PlayableActors, the safest choice for a game with playable characters) or AnyFree, which hides nothing and is the least safe. A player coming back with their key always gets their own seat. If a join fails because the game is full, raise MaxPlayers or kick a seat, and remember that away seats count. See the Settings reference.