Skip to content

Sending RPC to a Single Player

Tzian edited this page May 23, 2019 · 3 revisions

During your development process you may find that you have to send an RPC to a single player and nobody else. This is especially useful to target players that are just connecting to the server to send them needed data that is not buffered already.

General Example

// targetPlayer is a NetworkingPlayer refence we got from the NetWorker::Players list or anywhere else
// args is an object array

networkObject.SendRpc(targetPlayer, RPC_RPC_NAME, args);

Player Accept (join) Example

// Somewhere in your code

if (networker.IsServer)
    networker.playerAccepted += PlayerAcceptedSetup;

// ...

private void PlayerAcceptedSetup(NetworkingPlayer newPlayer, NetWorker sender)
    networkObject.SendRpc(newPlayer, RPC_RPC_NAME, args);


This player targeting with RPCs are done on the server. Clients do not have direct access to each other since all network traffic goes through the server (which makes it authoritative. You can use Receivers.Owner to target the owning player of the network object from any client though.


Getting Started
Network Contract Wizard (NCW)
Network Object
Remote Procedure Calls (RPCs)
Unity Integration
Basic Network Samples
Scene Navigation
Master Server
Web Server
Netcoding Design Patterns
Clone this wiki locally
You can’t perform that action at this time.