Collided Objects not destroyed

I have multiple objects and I want a character to collide with them. When it does, these objects are destroyed from the game. However, only the first object is detected and the rest do nothing when the character hits them. Here is the code:

function OnCollisionEnter (col : Collision) {
	if (col.gameObject.name == "objectname") {
		Destroy(col.gameObject);
	}
}

Both are set as rigidbodies. I thought this would be simple but I am not really sure why its not working.

Several possibilities :

  • The objects are not called “objectname”.
  • They are triggers
  • The character is a trigger
  • The character moves with transform, not physic
  • The character is a charactercontroller, OnCollisionEnter doesn’t work with it