Lobby and Matchmaking
Last updated
Last updated
The lobby server is a separate application that can help your players to find each other. Unlike the game server, the lobby server only needs to be run once, and as many players as you want can connect to it (as long as the server specs allows it). Once a player joins a game room and starts the game, it will disconnect from the lobby server and connect to the host or game server.
The lobby server can be used with any of the 3 network types. To change which network type the lobby uses, edit the Resources/NetworkData file.
The lobby server itself is always dedicated, but after the player connects to a game, it will connect to the appropriate host (either peer-to-peer to another player, or through the relay, or to a dedicated game server).
The lobby server also includes matchmaking features.
When the lobby is in dedicated server mode, the lobby will also take care of starting the dedicated game servers (one for each game, and each one with a different port). To make this work, you need to include the game server build inside a folder (the path can be set in NetworkData).
The path is absolute, unless it starts with ./ or ../
In that case the path is relative to unity’s Application.dataPath, which is either the data folder of the build, or the assets folder of the unity project.
This example would allow you to run the lobby in dedicated mode from Unity:
To build the lobby server, you only need to include one scene: ServerLobby.
For players to access to lobby, they can do it from this scene: MenuLobby
For online play, you will need to upload and run your lobby server executable on a cloud server. If in dedicated server mode, you need to do the same with the game server executable. More info on this in another document: Cloud Server Setup.