0
0
Unityframework~10 mins

Lobby and matchmaking basics in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new lobby with a maximum of 4 players.

Unity
var options = new CreateLobbyOptions { MaxPlayers = [1] };
LobbyService.Instance.CreateLobbyAsync("MyLobby", options);
Drag options to blanks, or click blank then click option'
A2
B4
C8
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Setting MaxPlayers to 1 limits the lobby to only one player.
Using a number larger than intended can cause unexpected behavior.
2fill in blank
medium

Complete the code to join a lobby by its ID.

Unity
var lobby = await LobbyService.Instance.JoinLobbyByIdAsync([1]);
Drag options to blanks, or click blank then click option'
A"gameMode"
B"lobbyName"
C"playerName"
D"12345"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the lobby name instead of the lobby ID.
Passing player or game mode strings instead of the lobby ID.
3fill in blank
hard

Fix the error in the code to properly list all available lobbies.

Unity
var lobbyList = await LobbyService.Instance.[1]();
Drag options to blanks, or click blank then click option'
AListLobbiesAsync
BRetrieveLobbies
CFetchLobbies
DGetAllLobbiesAsync
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method name that does not exist in the LobbyService API.
Forgetting the 'Async' suffix for asynchronous methods.
4fill in blank
hard

Fill both blanks to create a lobby and set it to be private.

Unity
var options = new CreateLobbyOptions { [1] = 6, [2] = true };
await LobbyService.Instance.CreateLobbyAsync("PrivateLobby", options);
Drag options to blanks, or click blank then click option'
AMaxPlayers
BIsPrivate
CIsPublic
DPlayerCount
Attempts:
3 left
💡 Hint
Common Mistakes
Using IsPublic instead of IsPrivate.
Confusing PlayerCount with MaxPlayers.
5fill in blank
hard

Fill all three blanks to update the lobby's data with a new game mode and max players.

Unity
var updateOptions = new UpdateLobbyOptions {
    Data = new Dictionary<string, DataObject> {
        { "GameMode", new DataObject(DataObject.VisibilityOptions.Public, [1]) }
    },
    [2] = [3]
};
await LobbyService.Instance.UpdateLobbyAsync(lobby.Id, updateOptions);
Drag options to blanks, or click blank then click option'
A"Deathmatch"
BMaxPlayers
C8
D"CaptureTheFlag"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong game mode string.
Mixing up the property names for max players.