hello
my animation doesnt function
i dont now why, but all is ok(in my opinion)
can you help me?
i have two scripts and i dont now whats wrong!
help!
function OnCollisionEnter(hit: Collision){
if(hit.gameObject.tag == "Player"){
AnimationAI._animation=2;
Attributes._hp-=AIlife.damage;
}
}
[/code]
#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");
break;
case(3):
GetComponent.<Animation>().Play("waitingforbatle");
break;
case(4):
GetComponent.<Animation>().Play("diee");
break;
}
}
i think :
the animation doenst have time to complete.
You put the “play animation” in the Update function. The update function runs many times a second. That means that dozens of times per second, your update function is checking the _animation value, finding out that it’s “2”, and then running “GetComponent.().Play(“attackk”);” right? You only need to play it once.
However, I don’t use Javascript and I don’t use the deprecated animation system you’re using, so that’s as far as I can help you.
i dont understand, can you create the correct code for me?
Nope, this is a simple logic problem. You’re running the “play animation” code dozens of times per second, because it’s in the Update() function. All you have to do is run it once and it’ll play the animation all of the way through, so you need to call it ONCE. Again, I don’t use Javascript.
thanks but thats doesnt function
ok my question is:
when my enemy start the animation “correr”
he cant start “attackk” animation
but i need:
he stop the correr animation when he start the attackk
how i do that?
the scripts are in my first post!