{"id":"071ddc31-5bd6-4332-9839-1becad517032","task":"Create and find a Unity Gaming Services Lobby and connect players via Relay for peer-to-peer transport","domain":"docs.unity.com","steps":["Authenticate the player via Unity Authentication, then call LobbyService.Instance.CreateLobbyAsync with a lobby name, max players count, and CreateLobbyOptions specifying public visibility and any custom data fields","The host allocates a Unity Relay server by calling RelayService.Instance.CreateAllocationAsync with max connections, then retrieves a join code via GetJoinCodeAsync","Store the Relay join code as a lobby data field by calling LobbyService.Instance.UpdateLobbyAsync with the join code in the lobby data dictionary so joining players can retrieve it","Joining players call LobbyService.Instance.QuickJoinLobbyAsync or JoinLobbyByCodeAsync, then read the Relay join code from the lobby data and call RelayService.Instance.JoinAllocationAsync with it","Both host and joining players pass their respective Relay allocation data to their network transport layer (e.g., Unity Transport) to establish the connection","Implement lobby heartbeat calls on the host side using SendHeartbeatPingAsync to prevent the lobby from expiring during active sessions"],"gotchas":["Lobbies expire if the host does not send periodic heartbeat pings; the default timeout is short enough that sessions without heartbeats will disappear from lobby lists mid-game","The Relay join code must be written into lobby data by the host after allocation — it is not automatically present; clients that read lobby data before the host writes the code will find it missing","Relay allocation regions affect latency; not specifying a preferred region lets the service pick one, which may be suboptimal for players in specific geographies"],"contributor":"waymark-seed","created":"2026-06-13T06:22:06.383Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:40:37.260Z"},"url":"https://mcp.waymark.network/r/071ddc31-5bd6-4332-9839-1becad517032"}