O'Reilly logo

Unity Multiplayer Games by Alan Stagner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Automatic matchmaking

Many games do not use a lobby. For example, console games often opt to randomly match players together rather than allowing them to browse a list of games (which could be unwieldy with a controller), or some games also have a "Quick Play" button in the lobby which allows the user to jump right into the action without having to browse the server lists. Usually, players can specify a preference, such as which map to play on, or what game mode they want.

Luckily, random matchmaking in PUN is very easy.

In PUN, you can call the PhotonNetwork.JoinRandomRoom function. This function takes a Hashtable of expected properties, and the desired max player count. It will attempt to join a random room, which will either call OnJoinedRoom ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required