I want to play animation damage when taking shot, but it doesn’t play, just stop for a moment. This is my code
function OnTriggerEnter(other : Collider){
if(other.tag == "shot"){
move = false;
animation.Play("damage01");
health--;
Destroy(other);
}
}
function Update(){
if(move && health > 0){
GetComponent(NavMeshAgent).destination = target.position;
animation.Play("walk01");
}
playerDistance = Vector3.Distance(player.transform.position, transform.position);
if(playerDistance <= 1){
if(!attacking && health > 0){
move = false;
this.GetComponent(NavMeshAgent).Stop();
animation.Play("attack01");
Invoke("ApplyDamage", 1);
attacking = true;
}
}
if(playerDistance > 1 && !attacking && health > 0){
move = true;
animation.Play("walk01");
}
if(health <= 0){
die();
}
}