PhotonView.RPC C# (CSharp) Method

RPC() public method

Call a RPC method of this GameObject on remote clients of this room (or on all, inclunding this client).
[Remote Procedure Calls](@ref rpcManual) are an essential tool in making multiplayer games with PUN. It enables you to make every client in a room call a specific method. This method allows you to make an RPC calls on a specific player's client. Of course, calls are affected by this client's lag and that of remote clients. Each call automatically is routed to the same PhotonView (and GameObject) that was used on the originating client. See: [Remote Procedure Calls](@ref rpcManual).
public RPC ( string methodName, PhotonPlayer, targetPlayer ) : void
methodName string The name of a fitting method that was has the RPC attribute.
targetPlayer PhotonPlayer, The group of targets and the way the RPC gets sent.
return void
    public void RPC(string methodName, PhotonPlayer targetPlayer, params object[] parameters)
    {
        PhotonNetwork.RPC(this, methodName, targetPlayer, false, parameters);
    }

Same methods

PhotonView::RPC ( string methodName, PhotonTargets target ) : void

Usage Example

Example #1
0
 public void Damage(float damage)
 {
     if (Currenthealth - damage <= 0)
     {
         DieEvent?.Invoke();
     }
     else
     {
         PhotonView?.RPC("DamageRPC", RpcTarget.All, damage);
     }
 }
All Usage Examples Of PhotonView::RPC