Animation (591176)

#pragma strict
static var _animation:int;
function Start () {
}
function Update () {
switch(_animation){
case(0):
GetComponent.<Animation>().Play("idlee");
break;
case(1):
GetComponent.<Animation>().Play("correr");
break;
case(2):
GetComponent.<Animation>().Play("attackk");
case(3):
GetComponent.<Animation>().Play("waitingforbattle");
break;
case(4):
GetComponent.<Animation>().Play("diee");
break;
}
}

my animation has a problem
if i start the animation correr
the animation attack doesnt start
but i need start the animation attack
how i do that?

#pragma strict
static var _animation:int;
function Start () {
}
function Update () {
switch(_animation){
case(0):
GetComponent.<Animation>().Play("idlee");
break;
case(1):
GetComponent.<Animation>().Play("correr");
break;
case(2):
GetComponent.<Animation>().Play("attackk");
case(3):
GetComponent.<Animation>().Play("waitingforbattle");
break;
case(4):
GetComponent.<Animation>().Play("diee");
break;
}
}

You are starting the animations in Update(). Update() runs every frame. If you start an animation every frame then it’ll always be at the start of the animation and look like it’s not playing or paused.

doesnt function!
look at my other script

#pragma strict
var Player: Transform;
var SpeedRotate: float;
var SpeedEnemy:float;
var _time:float;
var _MaxDistance:int;
function Start () {
_time=2;
_MaxDistance=1;
}
function Update () {
AnimationAI._animation=0;
if(Player!=null){
                if(Vector3.Distance(Player.position,transform.position)<20){
                        var rotate= Quaternion.LookRotation(Player.position - transform.position);
                        //Rotaçao do inimigo
                        transform.rotation=Quaternion.Slerp(transform.rotation,rotate,SpeedRotate*Time.deltaTime);
                        //Movimentaçao  do inimigo
                        if(Vector3.Distance(Player.position,transform.position)>_MaxDistance){
                                transform.Translate(0,0,SpeedEnemy*Time.deltaTime);
                                AnimationAI._animation=1;
                              
                        }
             
                }
                if(Vector3.Distance(Player.position,transform.position)<1){
                _time+=1*Time.deltaTime;
             
                if(_time>4){
                AnimationAI._animation=2;
                Attributes._hp+=-1;
                _time=0;
                }
                }
        }
}

and the damage script

     function OnCollisionEnter(hit: Collision){
         if(hit.gameObject.tag == "Player"){

         AnimationAI._animation=2;
        

             Attributes._hp-=AIlife.damage;
         }

    }

how i put the animation without the update

because there are no class names i have to guess. The First Code you postet is in your class AnimationAI ?
Like Antony Blackett said you are starting your animations in every update. also you are setting your _animation integer in the second script every frame to 0.

without update
in your AnimationAI class

function PlayAnimation(_animation : int) {
   switch(_animation){
   case(0):
   GetComponent.<Animation>().Play("idlee");
   break;
   case(1):
   GetComponent.<Animation>().Play("correr");
   break;
   case(2):
   GetComponent.<Animation>().Play("attackk");
   case(3):
   GetComponent.<Animation>().Play("waitingforbattle");
   break;
   case(4):
   GetComponent.<Animation>().Play("diee");
   break;
   }
}

and than call your function in another script

AnimatorAI.PlayAnimation(2);

hope syntax is correct, im more in C# than Javascript. can someone verify ?

ok, once again… you’re using the old Animation system… if you look up and use the newer mecanim system with it’s state engine design it doesn’t have these issues:

that would be the next thing i would change. I’m also using Animator