Joining lobbies

Players can join a lobby by specifying a lobby ID or by providing a lobby code. Lobby codes are short, auto-generated codes that map to specific lobbies and are intended for players to share with each other. The lobby code for a lobby is available as a members-only lobby property.

Best practices

The Lobby service provides the best experience when requests are minimized. The Join API supports passing in player data as part of the Join call, so it's best to do that rather than making a Join call followed by a separate Update Player call after you've joined the lobby.

Join by specifying a lobby ID

The following code sample shows how to join a lobby by specifying a lobby ID:

Copy
C#
try
{
    await Lobbies.Instance.JoinLobbyByIdAsync("lobbyId");
}
catch (LobbyServiceException e)
{
    Debug.Log(e);
}

Join by providing a lobby code

The following code sample shows how to join a lobby with a code:

Copy
C#
try
{
    await Lobbies.Instance.JoinLobbyByCodeAsync("lobbyCode");
}
catch (LobbyServiceException e)
{
    Debug.Log(e);
}