ViewID + Sending Messages

Hello,

Correct me if I’m wrong, but isn’t a viewID the ID that the network gives to a gameObject to keep a reference of it?

I’m trying to get my Network.Instantiated projectile to send a damage message to who ever it hits, but I’m struggling to do that. So below is the script attached to my Projectile (arrow). What was happening is on CollisionEnter, if the hit is a player then hit.collider.SendMessageUpwards(damage), and then destroy the projectile… But no damage was never received.

So then I though I might need to use an RPC, so what I’m trying to do is use the vewID from the collider, and send a damage message:

function OnCollisionEnter(hit : Collision){

   if(hit.collider.gameObject.tag == "Player"){

      var viewID = hit.collider.Network.viewID;
      networkView.RPC("SendDamage", RPCMode.All, viewID, damage);
    }
Network.Destroy(GetComponent(NetworkView).viewID);
}

@RPC
function SendDamage(viewID : NetworkViewID, damage : float){

   var enemyID = NetworkView.Find(viewID);
   var enemy = enemyID.observed.gameObject;

   enemy.gameObject.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
}

But whats happening is that I get a NullException, at: var viewID = hit.collider.Network.viewID;

What do I need to do, to send damage to my collider object?

You need to be using:

 hit.collider.networkView.viewID