RPC bein sent multiple times as object is destroyed

Options
Attempting to send a RPC after a character attempts to pick up a neutral object, then destroy the pickup, this is causing the RPC to be received multiple times and i do not understand why.

void Update ()
{
if(objectDestroyed)
{
Destroy();
}

if (pickedUpBy != null && pickedUp == true && !objectDestroyed)
{
if (PhotonNetwork.isMasterClient == true)
{
pickedUpBy.GetComponent().photonView.RPC("Heal", PhotonTargets.All, healAmount);
}
pickedUpBy = null;
pickedUp = false;
objectDestroyed = true;
}
}

void OnTriggerEnter(Collider other)
{
if(other.tag == "Hero" && !pickedUp)
{
pickedUpBy = other.gameObject;
pickedUp = true;
}
}

void Destroy()
{
if (PhotonNetwork.isMasterClient == true)
{
PhotonNetwork.Destroy(gameObject);
}
}

Comments