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

RPC call not firing on clients photonview

$
0
0
When I fire off a RPC call, other clients receive it but only run on photonview's that aren't their own?

I have two photonviews 1001 and 2001.
For example, I'm doing this and the player with viewID 1001 sends this.

this.photonView.RPC("OnHit", PhotonTargets.Others);

The client who is in control of the avatar with photonview 2001 receives this RPC call but only generates it on the class attached to photonview 1001 and not itself.

This is the full code
[PunRPC]
public void OnHit(int hitViewID, int attackerViewID)
{
Debug.Log("hitReceived by" + attackerViewID + "intended for " + hitViewID + "but I am " + photonView.viewID);
}

void OnControllerColliderHit(ControllerColliderHit hit)
{
if(photonView.isMine)
{
// We dont want to push objects below us
if (hit.moveDirection.y < -0.3f || m_controller.velocity.magnitude < 0.2f)
return;

var brawler = hit.gameObject.GetComponent();
if (brawler != null)
{
var hitViewID = brawler.photonView.viewID;
this.photonView.RPC("OnHit", PhotonTargets.Others, hitViewID, photonView.viewID);
}
}
}


So what I'll end up with is "hitReceived by1001intended for 2001 but I am 1001". I'm at a loss, I am using RPC stuff elsewhere and it works fine.

Viewing all articles
Browse latest Browse all 8947

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>