Player Zero Lobby
The Player Zero platform allows players to form pre-game lobbies with their friends, then launch your Unity game together with synchronized session data.
When a host starts the game from the Player Zero website, the game is launched with metadata that helps your game:
Identify the lobby (
lobbyId
)Determine who is the host (
host
)Match all players to the correct region (
region
)
This page explains how to read this data inside your Unity project and use it to connect all players to the same multiplayer session, especially when using a networking solution like Photon.
🧩 What Player Zero provides to your game
When the game is launched from a Player Zero lobby, the following parameters are passed:
lobbyId
string
A shared ID for the session. Can be used as the room name or lobby code.
host
boolean
Indicates whether the current player is the lobby host.
region
string
The region code for the session (e.g., us
, eu
, etc). Use this to ensure all players connect to the same region and prevent connection issues.
🛠️ How to use this in Unity
The Player Zero SDK includes a helper class called ZeroLobby
that makes it easy to retrieve lobby data passed from the Player Zero platform.
You can use it to:
Check if lobby data is available
LobbyQueryHandler.CheckForLobby()
Get the lobby ID
LobbyQueryHandler.LobbyId
Check if the player is the host
LobbyQueryHandler.IsHost
Get the region of the host
LobbyQueryHandler.HostRegion
Call LobbyQueryHandler.CheckForLobby()
early in your game's startup flow to initialize and apply the correct values.
For example you might have a NetworkManager
class that checks for a lobby in the Start function.
The following code samples are using API's from Photon PUN2 networking plugin but the concepts should be the same for any Unity networking solution.
1. Use lobbyId
as your room name
lobbyId
as your room nameThis ensures that all players connect to the same room or lobby.
2. Use LobbyQueryHandler.IsHost
to determine role
LobbyQueryHandler.IsHost
to determine roleIf LobbyQueryHandler.IsHost == true
, the player should create the room. Otherwise, they should join the room.
3. Use region
to connect to the correct server
region
to connect to the correct serverPhoton normally selects a region based on the player's location. You'll want to force all players to use the host's region to prevent mismatched rooms.
4. Optionally send players back to Player Zero after the game ends
If you're building a WebGL game, the SDK includes a function that allows you to return players back to the Player Zero lobby after a game session ends
To trigger this behavior from your Unity code, call the following method:
Calling this will exit the game view and return the player to the Player Zero lobby interface.
Summary
By using lobbyId
, host
, and region
, you can ensure:
All players join the same room
The correct player creates the room
Everyone connects to the same region
This approach ensures a consistent multiplayer experience across all participants, especially when using cloud-based networking solutions like Photon.
Last updated