Send a message or RPC to single client?
Options
I haven't been able to find anything on this in the documentation, so if I've missed something I'd appreciate being pointed in the correct direction. Is it possible to send an RPC or raise an event to only a single client? This exists for MasterClient, which is great, but I don't see a way to send an event to a single client without spamming the room. Am I missing something obvious?
0
Comments
-
Hi, you can define Target Actor for event http://doc-api.photonengine.com/en/PUN/current/class_raise_event_options.html
https://doc.photonengine.com/en-us/pun/current/gameplay/rpcsandraiseeventPhotonNetwork.RaiseEvent(eventCode, content, reliable, new RaiseEventOptions { TargetActors = new int[] { PhotonPlayer.ID } });
For RPC im not sure.1 -
And the same is possible for RPC's
https://doc-api.photonengine.com/en/pun/current/class_photon_view.html#a6bc9726af14a8c7b8bdd7793c495a6e80 -
Sweet, thanks! That's very helpful.0
-
Does everyone receive the message but only the defined actors execute it? And if not, it would be better for traffic to send only to these clients which should execute it instead to just send to "others" and leave it as default, right?S_Oliver said:Hi, you can define Target Actor for event http://doc-api.photonengine.com/en/PUN/current/class_raise_event_options.html
https://doc.photonengine.com/en-us/pun/current/gameplay/rpcsandraiseeventPhotonNetwork.RaiseEvent(eventCode, content, reliable, new RaiseEventOptions { TargetActors = new int[] { PhotonPlayer.ID } });
For RPC im not sure.0 -
I dont know, hopefully @JohnTube or @Christian_Simon knows exactly, but I assume that the message/event only sends to the defined actor.0
-
if you send to target actors using their respective actor numbers than only those actors will receive the event / RPC.1
-
@JohnTube I want to send to the defined actors,could you tell me how to know the player's id?0
-
Hi @llliao_104,
It is not possible to send an RPC once to multiple "defined actors".
You can however send an RPC to a single actor using:PhotonNetwork.RPC(string methodName, Player targetPlayer, params object[] parameters) PhotonNetwork.RpcSecure(string methodName, Player targetPlayer, bool encrypt, params object[] parameters)
So you may call this once per target actor.
Otherwise, use RaiseEvent for that and set the target actors using their respective actor numbers in raiseEventOptions.TargetActors.0 -
RPC and RaiseEvent are equal speed for send data ?0