Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using [RPC] instead of [PunRPC]
Forgetting the attribute entirely
Using a non-existent attribute like [RemoteCall]
✗ Incorrect
In Unity with Photon, the attribute [PunRPC] marks a method as a remote procedure call.
2fill in blank
mediumComplete 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'
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
✗ Incorrect
The method photonView.RPC is used to call remote procedures on clients.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Including parentheses in the method name
Using camelCase instead of PascalCase
Using underscores in method names
✗ Incorrect
Method names should not include parentheses in declaration and should follow PascalCase by convention.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names that are not defined
Using quotes incorrectly around keys or values
✗ Incorrect
The dictionary keys should be player names as strings and values should be the score variable.
5fill in blank
hardFill 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'
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
✗ Incorrect
The condition checks if playerScore is greater than 50, then calls photonView.RPC to update score remotely.