Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

Why does OnTriggerEnter calls on client and master

$
0
0
Whenever I pass over a trigger with the code below it's called on both client and master.
private void OnTriggerEnter(Collider other) { PlayerTracker.Instance.ModifyHealth(PhotonNetwork.player, -10); }

public void ModifyHealth(PhotonPlayer photonPlayer, int value) { PhotonView.RPC("RPC_ModifyHealth", PhotonTargets.MasterClient, photonPlayer, value); }

The trigger does not have a photonview attached. I would expect it to call ModifyHealth on the player which travels into it, which then calls RPC_ModifyHealth on the master. This does happen, but RPC_Modify health is called once with the player triggering it as the argument, and again with the master as the argument.

It seems trigger is getting fired on client and master. Is this normal behavior? If so, how do you determine who actually hit the trigger?

Viewing all articles
Browse latest Browse all 8947

Trending Articles