CodeBlanks Logo Icon CodeBlanks

Lobby and room

Learn the lobby and room creation flow.

Lobby and Matchmaking Flow

In multiplayer games, the screen where players gather before a match and browse room lists is called a Lobby. The Matchmaking system automatically pairs players into optimal rooms based on skill level, region, or ping.

// Requesting to join a random available room
PhotonNetwork.JoinRandomRoom();

If no suitable room is found, the client automatically spins up a new room and waits for other participants to join.

Room Parameters and RoomOptions

When creating a room, parameters bounding the game session are configured. For instance, maximum player count (MaxPlayers) and public listing visibility (IsVisible) are specified.

RoomOptions options = new RoomOptions();
options.MaxPlayers = 4;
options.IsOpen = true;
PhotonNetwork.CreateRoom("Takim_Odasi", options);

Once the room hits capacity, the system locks it against new entrants and triggers the scene transition.

Practice Room capacity configuration

Define a Start method. Inside, declare int maxPlayers = 4; and print "Oda olusturuldu. Maksimum oyuncu: " + maxPlayers to the console.

Starter code

Player.cs
using UnityEngine;

public class RoomManager : MonoBehaviour
{
    // Start icinde maksimum oyuncu ve oda bilgisini yazdir
}

Sample solution

Player.cs
using UnityEngine;

public class RoomManager : MonoBehaviour
{
    void Start()
    {
        int maxPlayers = 4;
        Debug.Log("Oda olusturuldu. Maksimum oyuncu: " + maxPlayers);
    }
}

Expected output

Oda olusturuldu. Maksimum oyuncu: 4

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What is the system called that automatically pairs players into a room based on skill or connection metrics?

  • Audio Mixer
  • Garbage Collector
  • Matchmaking Correct answer
  • Shader Pipeline

Explanation: The matchmaking system automatically allocates players into suitable rooms according to predefined criteria (skill, ping, capacity).

2 Join random room

Question
PhotonNetwork.____();
Answer
PhotonNetwork.JoinRandomRoom();

Explanation: The 'JoinRandomRoom' method is used to quickly connect to any available room.

3 Room and matchmaking terms

Term Meaning
Lobby Lobby area where players select rooms
Matchmaking System automatically matching players
RoomOptions Room capacity and visibility settings
MaxPlayers Maximum player ceiling in a room

All lessons in Advanced