RPC call not firing on clients photonview

Options
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<BrawlBaseController>();
            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.

Comments

  • Ryanas
    Options
    Ah nevermind, so stupid.

    I want to call the photonview of the object I'm trying to get the RPC to trigger on. I just did brawler.photonview.RPC now. Whoops!