Network.Destroy in OnCollisionEnter; not working.

I’m in the process of learning Unity’s network features (so please excuse any horrendous code I paste), and I’m having trouble with a Network.Destroy inside an OnCollisionEnter.

Current function is as follows:

function OnCollisionEnter(collision : Collision)
{
	if (networkView.isMine && collision.collider.gameObject == target)
	{
		Network.Destroy(gameObject);
		Debug.Log("Destroyed");
	}
}

The log won’t even work, so I’m guessing it’s to do with the if statement. This script is obviously attached to the object I want to destroy, while the ‘target’ (set through the inspector as a variable) is the other object. Both objects have rigidbodies and colliders, and neither are set as triggers. They are both also prefabs, if that makes any difference. Thanks for any help.

The Prefab is not the same as the instance which is colliding with this gameobject. You should do your gameobject detection with tags. Just add a tag to the bullet like “Bullet” and then you can do:

if (networkView.isMine && collision.collider.gameObject.tag == "Bullet")