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.
↧