Problem with collisions and Destroy(gameObject).

I'm making a Space Invaders clone for my first unity project so I can get comfortable with the engine. I'm trying to make the bullet colliding with the ship destroys the ship. Here is the code:

function OnControllerColliderHit (hit:ControllerColliderHit)
{
        if (hit.gameObject.tag == "bullet")
        {
                Destroy(gameObject);    
        }
}

I have the code attached to the ship and the bullet has the "bullet" tag. My question is why isn't the ship being destroyed?

Edit:

I changed the code to:

function OnControllerColliderHit (hit:ControllerColliderHit)
{
        Debug.Log("Collision Works");if (hit.gameObject.tag == "bullet")
        {
                Destroy(gameObject);    
        }
}

It did not say the collision works in the console. Thanks for all the help by the way =)

If the debug isn't being called then the function isn't running.

So, make sure you do in fact have a CharacterController on the ship. Otherwise, you should use `OnCollisionEnter()`.

Make sure you are moving your bullets using Unity's physics engine. If you use Transform.Translate() to move your bullets then the message won't be sent either.

For the character controller, you should use exclusively `Controller.Move()`.

to narrow down where your code is not working you can use `Debug.Log(message);` to let you know what is actually happening. because with this code either `OnControllerColliderHit` is not getting called or the `hit.gameObject.tag` is never "bullet".

logging a message "collider hit" inside `OnControllerColliderHit` would let you know that it is in fact getting called.