Enemy Animation

Guys, I have a enemy with 2 animations, one is when he is acting normally (tag = principal [[I’m Brazilian]]), and another called ‘‘hit’’.
But what happens is that only the ‘‘principal’’ animation is started, and when I collide with the enemy [it have a box collider], he doesn’t go away, and the ‘‘hit’’ animation isn’t even started. My friend told me to use a var=boolean, but I have no ideia of how do I use.
This is the code

.

#pragma strict

function Start () {

}

function Update () {
animation.Play("Principal");

}
function OnCollisionEnter(collision: Collision)
{
    if (collision.gameObject.tag == "Player")
    {
    animation.Play("Hit");
        Destroy(gameObject, 3);
       
        }
     
}

Thnks guys, and sorry for my horrible English... I'm Brazilian

You have your principal animation in the update so it’s going to play no matter what. You have to stop it and then play the other animation. You could do this with a bool, but if you don’t know how to do that, I would suggest that you take a few more tutorials from the learn section. Basically you would do something like this above any code:
var idling:bool = true;
in update:
if(idling)animaton.Play(“Principal”);
in collision:
if(collision.gameObject.tag == “Player”)
{
animation.Stop();
idling = false;
animation.Play(“Hit”);
waitAndDestroy();

}
function waitAndDestroy(){
yield return WaitForSeconds(3);
Destroy(gameObject);
}

Really, though, it would be better to set the animation to loop and start it in the start function. Then you wouldn’t need the bool.