Photon Unity

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 PUN.

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.

Photon Unity : Send an RPC Function to one specific player to execute.

Mido135
2020-06-23 20:14:32

i just want to know how to send an rpc function to one player using Raycast, i looked up for tutorials but cant find any , i would appreciate it if someone can explain to me how, thanks in advance.

Comments

lmartell
2020-06-24 00:27:39

Haven't done it and just typing code from memory... but something like this should work inside your Raycast block:

var hitPhotonView = hit.collider.gameObject.GetComponentInParent<PhotonView>();  
if(hitPhotonView != null)  
   photonView.RPC("RPCName", hitPhotonView.owner);

Mido135
2020-06-24 11:51:31

thanks for responding, so when the owner execute this function, will his health for example be sycronized with all other players even if we don t use RPCtarget.all .

jeffries7
2020-06-25 14:02:31

The health would always be calculated locally meaning, Player B doesn't need to know the health of Player A. Player A tags damage then anything thing resulting from that would be replicated over the network, such as death or specific animations.

Are you referring to UI when you talk of synchronized health?

Back to top