How to invoke RPC on master client?

Options

I want to send a static RPC from any client to the master client in shared mode.

The problem is, that the RPC seems to be run locally ( which I do not want ).

Also, it is not run on the target machine, i.e. master client.


What am I doing wrong? I read that the master client is always the PlayerRef with the last index.


Calling code:

var numPlayers = _networkRunner.ActivePlayers.Count();

PlayerRef masterClient = numPlayers;

RPC_Log(_networkRunner, masterClient, "Hello RPC!");


Rpc signature:

public static void RPC_Log(NetworkRunner runner, [RpcTarget] PlayerRef player, string logMessage, RpcInfo info = default) {}

Answers

  • morrison
    Options

    Is it not possible to do this with Fusion?

  • Tobias
    Options

    You can limit where it's running, as long as it's not a static RPC method.

    My suggestion would be to just not make it static and use the attribute RpcTargets.

  • ramonmelo
    Options

    Hi @morrison ,


    Is there any particular reason to target the Master Client?

    We don't suggest attaching any logic that targets the Master Client, instead, you should target either the State or the Input authority of a NetworkObject.

    Also, it is not guaranteed that the Master Client will be the Player with the lasted ID, as the Master Client "flag" is transferred to other clients when the original Master Client leaves the Session. 


    --

    Ramon Melo

    Photon Fusion Team