0
0
Unityframework~10 mins

Client-server architecture 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 start the server in Unity.

Unity
NetworkManager.singleton.Start[1]();
Drag options to blanks, or click blank then click option'
AClient
BConnect
CHost
DServer
Attempts:
3 left
💡 Hint
Common Mistakes
Using StartClient() instead of StartServer()
Using StartHost() which starts both client and server
2fill in blank
medium

Complete the code to send a message from client to server.

Unity
client.Send[1](message);
Drag options to blanks, or click blank then click option'
ACommand
BMessage
CRpc
DEvent
Attempts:
3 left
💡 Hint
Common Mistakes
Using Rpc which is server to client
Using Event which is not a Unity networking method
3fill in blank
hard

Fix the error in the server callback method declaration.

Unity
[[1]]
void CmdSendData(string data) {
    // server logic
}
Drag options to blanks, or click blank then click option'
AServerCallback
BClientRpc
CCommand
DServerRpc
Attempts:
3 left
💡 Hint
Common Mistakes
Using ClientRpc attribute instead of Command
Using ServerRpc which is not a Unity HLAPI attribute
4fill in blank
hard

Fill both blanks to create a dictionary of player scores where keys are player IDs and values are scores greater than 10.

Unity
var highScores = new Dictionary<int, int> { { [1], [2] } };
Drag options to blanks, or click blank then click option'
AplayerId
Bscore
C15
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using score as key instead of playerId
Using 5 as score which is not greater than 10
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps player names to their scores if the score is above 50.

Unity
var topPlayers = new Dictionary<string, int> { { [1], [2] } }; // Only if [3] > 50
Drag options to blanks, or click blank then click option'
AplayerName
Bscore
DplayerId
Attempts:
3 left
💡 Hint
Common Mistakes
Using playerId instead of playerName as key
Using playerId in the condition instead of score