How to invoke RPC on master client?
The whole answer can be found below.
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).
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
Is it not possible to do this with Fusion?
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.
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