How to invoke RPC on master client?

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on Fusion.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

How to invoke RPC on master client?

morrison
2022-02-19 21:23:15

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) {}

Comments

morrison
2022-03-03 13:58:10

Is it not possible to do this with Fusion?

Tobias
2022-03-08 14:01:09

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
2022-03-30 09:10:06

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

Back to top