Simple script request ... if i hit myself destroy me

Simple enough but I’m still impossible with the whole syntax of Collision : collision and oncollsionenter () where I always get errors.

Simply put … put a small script on a GameObject that says if I collide with another instance of me (the same object), destroy me.

Thanks.

Possibly:

function OnCollisionEnter(other : Collision) {
   if (other.collider.gameObject.name == gameObject.name) {
      Destroy(gameObject);
   }
}

?

–Eric

When you mean “same object”, do you mean if you hit another object that has the same component as the one doing the check? If so, this works (C#, sorry):

void OnCollisionEnter(Collision col)
{
	if(col.gameObject.GetComponent(this.GetType()))
	{
		print("hit object of same component");
	}
}