0
0
Unityframework~10 mins

Remote procedure calls 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 declare a remote procedure call method in Unity.

Unity
[[1]]
public void SendMessageToServer(string message) {
    Debug.Log(message);
}
Drag options to blanks, or click blank then click option'
ARPC
BPunRPC
CRemoteCall
DNetworkCall
Attempts:
3 left
💡 Hint
Common Mistakes
Using [RPC] instead of [PunRPC]
Forgetting the attribute entirely
Using a non-existent attribute like [RemoteCall]
2fill in blank
medium

Complete the code to call a remote procedure on all connected clients.

Unity
photonView.[1]("SendMessageToServer", RpcTarget.All, "Hello everyone!");
Drag options to blanks, or click blank then click option'
AInvokeRPC
BCallRemote
CRPC
DSendRPC
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method name like CallRemote or SendRPC which do not exist
Trying to call the method directly without photonView
3fill in blank
hard

Fix the error in the remote procedure call method declaration.

Unity
[PunRPC]
public void [1](string message) {
    Debug.Log(message);
}
Drag options to blanks, or click blank then click option'
ASendMessageToServer
BSend_Message
CSendMessageToServer()
DsendMessageToServer
Attempts:
3 left
💡 Hint
Common Mistakes
Including parentheses in the method name
Using camelCase instead of PascalCase
Using underscores in method names
4fill in blank
hard

Fill both blanks to create a dictionary that maps player names to their scores.

Unity
var highScores = new Dictionary<string, int> { { [1], [2] } };
Drag options to blanks, or click blank then click option'
A"playerName"
Bscore
CplayerScore
D"score"
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names that are not defined
Using quotes incorrectly around keys or values
5fill in blank
hard

Fill all three blanks to send a remote call only if the player score is greater than 50.

Unity
if ([1] [2] 50) {
    photonView.[3]("UpdateScore", RpcTarget.All, playerScore);
}
Drag options to blanks, or click blank then click option'
AplayerScore
B>
CRPC
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable name in the condition
Using incorrect comparison operators
Using a wrong method name instead of RPC