Collision detection on cube with third person camera

What I want is to be able to destroy the cube when the third person character hits the cube…I have this code so far:

#pragma strict

var other : GameObject;

function Start () {

}

function Update () {

   



}


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

But it is not working, the third person camera is called ‘Character’, and the cube is called ‘Cube1’.

Any suggestions will be appreciated!

Check your Collision with Tags.

  1. Make your own Tag example “Person”
  2. Add the Tag to all GameObjects from your Charactercontroller
  3. Write in the Script gameobject.tag == “Person”

Then may it works.