Version: 2022.3
LanguageEnglish
  • C#
Removed

NetworkView.RPC

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Obsolete The legacy networking system has been removed in Unity 2018.2. Use Unity Multiplayer and NetworkIdentity instead.

Declaration

public void RPC(string name, RPCMode mode, params object[] args);

Description

Call a RPC function on all connected peers.

The called function must have the @RPC tag set ([RPC] for C Sharp code). A NetworkView must be attached to the GameObject where the RPC function is being called. It doesn't matter if the NetworkView is being used for something else or just for the RPC function. If it is just for the RPC function, state synchronization should be turned off and the observed property can be set to none. RPC function names should be unique accross the Scene, if two RPC functions in different scripts have the same name only one of them is called when RPC is invoked. RPC calls are always guaranteed to be executed in the same order as they are sent. The communication group set for the network view, with NetworkView.group, is used for the RPC call. To get information on the RPC itelf, you can add a NetworkMessageInfo parameter to the function declaration which will automatically contain the information. You don't need to change the way you call the RPC function when you do this. For more information see the RPC section of the manual. Valid RPC parameters are int, float, string, NetworkPlayer, NetworkViewID, Vector3 and Quaternion.


Obsolete The legacy networking system has been removed in Unity 2018.2. Use Unity Multiplayer and NetworkIdentity instead.

Declaration

public void RPC(string name, NetworkPlayer target, params object[] args);

Description

Call a RPC function on a specific player.