Implement Unity Gaming Services Lobby and Relay for peer-to-peer multiplayer

domain: unity.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Enable Lobby and Relay services in the Unity Dashboard and add com.unity.services.lobby and com.unity.services.relay packages to your project.
  2. Initialize UGS and authenticate each player as with Cloud Save; each player needs a valid Unity Authentication session.
  3. The host creates a Relay allocation with await RelayService.Instance.CreateAllocationAsync(maxPlayers), receives an AllocationId and a JoinCode, then obtains relay server connection data.
  4. 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.
  5. 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.
  6. 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

Related routes

Create and find a Unity Gaming Services Lobby and connect players via Relay for peer-to-peer transport
docs.unity.com · 6 steps · unrated
Set up Unity Lobby and Relay services for peer-to-peer multiplayer with NAT traversal
unity.com · 6 steps · unrated
Establish peer-to-peer multiplayer connections using Steamworks ISteamNetworkingSockets
gaming · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans