Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The maximum number of players is set to 4 to allow up to 4 players in the lobby.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
You need to provide the lobby ID as a string to join the correct lobby.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The correct method to list all lobbies is ListLobbiesAsync.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using IsPublic instead of IsPrivate.
Confusing PlayerCount with MaxPlayers.
✗ Incorrect
MaxPlayers sets the maximum players, and IsPrivate makes the lobby private.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong game mode string.
Mixing up the property names for max players.
✗ Incorrect
The game mode is set to "Deathmatch", MaxPlayers is updated to 8.