Enable Lobby and Relay services in the Unity Dashboard and add com.unity.services.lobby and com.unity.services.relay packages to your project.
Initialize UGS and authenticate each player as with Cloud Save; each player needs a valid Unity Authentication session.
The host creates a Relay allocation with await RelayService.Instance.CreateAllocationAsync(maxPlayers), receives an AllocationId and a JoinCode, then obtains relay server connection data.
The host creates a Lobby with await LobbyService.Instance.CreateLobbyAsync(lobbyName, maxPlayers, options) and stores the Relay JoinCode in lobby data so clients can retrieve it.
Clients query or join the lobby with JoinLobbyByCodeAsync or QueryLobbiesAsync; on joining, they read the Relay JoinCode from lobby data and call RelayService.Instance.JoinAllocationAsync(joinCode) to get their relay connection details.
Pass the relay connection data (server endpoint, allocation ID, connection data) to your transport layer (e.g., Unity Transport / Netcode for GameObjects) to establish the actual connection through Relay's TURN server.
Known gotchas
Relay is a TURN relay service — traffic routes through Unity's servers, adding latency; it is not a matchmaking or game server solution, and host migration is your responsibility if the host disconnects.
Lobby data updated by the host is not pushed to clients in real time by default; clients must poll with GetLobbyAsync or subscribe to lobby change callbacks using LobbyService.Instance.SubscribeToLobbyChangesAsync.
Relay allocations expire if unused for a short period (around 10 seconds) before the host binds to them — create the relay allocation, bind immediately in your transport layer, then create the lobby rather than creating the lobby first.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp