Search Unity

Question How to execute RPC calls on all clients when this method sent from one client?

Discussion in 'Netcode for GameObjects' started by andreyshade, Apr 19, 2022.

  1. andreyshade

    andreyshade

    Joined:
    Aug 8, 2017
    Posts:
    10
    Ho to execute RPC calls on all clients when this method sent from one client? Is it exists some solution in Unity netcode like RPCTargets.All in Photon?
     
  2. CosmoM

    CosmoM

    Joined:
    Oct 31, 2015
    Posts:
    204
    I'm not entirely sure what you mean, but clients can only call ServerRpcs (that then run on the server). Only the server can call ClientRpcs, which by default calls the method on all clients. If you only want to to call the method on specific clients, add an optional ClientRpcParams parameter to the method and set TargetClientIds, see here.
     
  3. Cathair

    Cathair

    Joined:
    Mar 23, 2022
    Posts:
    3
    Have you tried this logic?

    1. Call a ServerRpc from your client
    2. Call ClientRpc from the server