An RPC in Unity is a way to call a function on another computer or player over the network, making multiplayer games work smoothly.
Click to reveal answer
beginner
How do you mark a method as an RPC in Unity's networking system?
You mark a method with the [PunRPC] attribute when using Photon, or use [ClientRpc] in Unity's Netcode for GameObjects to indicate it can be called remotely.
Click to reveal answer
intermediate
What is the difference between a ClientRpc and a Command in Unity networking?
A Command is called by a client to run code on the server, while a ClientRpc is called by the server to run code on clients.
Click to reveal answer
intermediate
Why should RPCs be used carefully in multiplayer games?
Because RPCs send data over the network, using too many or large RPCs can cause lag or slow down the game experience.
Click to reveal answer
beginner
Give an example of a simple RPC method in Unity using Photon.
Example:
[PunRPC]
void Jump() {
// Make the player jump
}
Click to reveal answer
What does an RPC do in Unity multiplayer games?
ACalls a function on another player or server over the network
BSaves game data locally
CDraws graphics on the screen
DHandles user input only
✗ Incorrect
RPCs let you run code on other players' computers or the server, enabling multiplayer interaction.
Which attribute is used to mark a method as an RPC in Photon Unity Networking?
A[ClientRpc]
B[PunRPC]
C[Command]
D[Remote]
✗ Incorrect
Photon uses [PunRPC] to mark methods that can be called remotely.
In Unity's Netcode for GameObjects, what does a ClientRpc do?
ARuns code on clients from the server
BRuns code on the server from clients
CSaves player preferences
DHandles physics calculations
✗ Incorrect
ClientRpc methods are called by the server to execute code on all or specific clients.
Why should you limit the number of RPC calls in your game?
ARPCs slow down graphics rendering
BRPCs use too much memory locally
CToo many RPCs can cause network lag
DRPCs are not supported on mobile devices
✗ Incorrect
Excessive RPC calls increase network traffic and can cause lag.
Which of these is NOT a typical use of RPCs in Unity multiplayer?
ASynchronizing player actions
BTriggering animations on other players
CUpdating game state across players
DLoading local game assets
✗ Incorrect
Loading local assets is done locally, not via RPCs.
Explain how Remote Procedure Calls help multiplayer games in Unity work.
Think about how players see each other's actions in real time.
You got /3 concepts.
Describe the difference between ClientRpc and Command in Unity networking.
Who calls whom in each case?
You got /3 concepts.
Practice
(1/5)
1. What attribute do you use in Unity to make a method run on the server when called from a client?
easy
A. [ServerRpc]
B. [ClientRpc]
C. [RunOnServer]
D. [RemoteCall]
Solution
Step 1: Understand the direction of the call
Client-to-server calls require a special attribute to mark the method that runs on the server.
Step 2: Identify the correct attribute in Unity
Unity uses [ServerRpc] to mark methods that clients call to run on the server.
Final Answer:
[ServerRpc] -> Option A
Quick Check:
Client-to-server calls use [ServerRpc] [OK]
Hint: Client calls server methods with [ServerRpc] attribute [OK]
Common Mistakes:
Confusing [ClientRpc] as client-to-server
Using non-existent attributes like [RunOnServer]
Thinking [RemoteCall] is a valid Unity attribute
2. Which of the following is the correct syntax to declare a server RPC method in Unity?
easy
A. public void MyMethod() { }
B. [ServerRpc] public void MyMethod() { }
C. [ClientRpc] public void MyMethod() { }
D. void [ServerRpc] MyMethod() { }
Solution
Step 1: Recall the attribute placement
Attributes in C# go before the method declaration.
Step 2: Check the correct attribute and syntax
The correct syntax is [ServerRpc] public void MyMethod() { }. void [ServerRpc] MyMethod() { } places the attribute incorrectly.
Final Answer:
[ServerRpc] public void MyMethod() { } -> Option B
Quick Check:
Attributes precede method declarations [OK]
Hint: Attributes go before method signature in C# [OK]
D. Method name suggests client RPC but uses [ServerRpc] attribute
Solution
Step 1: Analyze method name and attribute
The method name contains "ClientRpc" but the attribute is [ServerRpc], which is confusing and likely a mistake.
Step 2: Check RPC method rules
RPC methods can have parameters and must have a return type (void is valid). They can be public. The mismatch between name and attribute is the main issue.
Final Answer:
Method name suggests client RPC but uses [ServerRpc] attribute -> Option D
Quick Check:
Method name and attribute must match RPC direction [OK]
Hint: Match method name with RPC attribute to avoid confusion [OK]
Common Mistakes:
Ignoring method name and attribute mismatch
Thinking parameters are not allowed
Assuming RPC methods must be private
5. You want to send a message from the server to all clients except the one who sent the original request. Which approach using Unity RPCs is correct?
hard
A. Use [ClientRpc] with a special NetworkConnection parameter to exclude sender
B. Use [ServerRpc] to send message to clients except sender
C. Use [ClientRpc] and check inside the client to ignore messages from itself
D. Use [ClientRpc] with a parameter to exclude the sender client inside the method
Solution
Step 1: Understand RPC direction
Server sends messages to clients using [ClientRpc]. To exclude a client, the server must know which client to exclude.
Step 2: Use NetworkConnection parameter
Unity allows [ClientRpc] methods to take a NetworkConnection parameter to exclude that client from receiving the RPC.
Step 3: Confirm other options
Use [ClientRpc] with a parameter to exclude the sender client inside the method is incorrect because exclusion logic cannot be done inside the client method. Use [ServerRpc] to send message to clients except sender is wrong direction. Use [ClientRpc] and check inside the client to ignore messages from itself relies on client ignoring messages, which is inefficient.
Final Answer:
Use [ClientRpc] with a special NetworkConnection parameter to exclude sender -> Option A
Quick Check:
Exclude sender with NetworkConnection parameter in ClientRpc [OK]
Hint: Exclude sender using NetworkConnection param in ClientRpc [OK]
Common Mistakes:
Trying to exclude sender inside client code
Using ServerRpc to send to clients
Not using NetworkConnection parameter for exclusion
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.