I have put boolean like this
function OnTriggerEnter(other : Collider){
if(other.tag == "shot"){
move = false;
hurt = true;
health--;
Destroy(other);
}
}
but it never change as I type in function update
function Update(){
if(move && health > 0 && !hurt){
GetComponent(NavMeshAgent).destination = target.position;
animation.Play("walk01");
}
if(hurt && health > 0){
animation.Play("damage01");
hurt = false;
}
playerDistance = Vector3.Distance(player.transform.position, transform.position);
if(playerDistance <= 1){
if(!attacking && health > 0 && ! hurt){
move = false;
this.GetComponent(NavMeshAgent).Stop();
animation.Play("attack01");
Invoke("ApplyDamage", 1);
attacking = true;
}
}
if(playerDistance > 1 && playerDistance <= 10 && !attacking && health > 0 && !hurt){
move = true;
animation.Play("walk01");
}
if(playerDistance > 10 && health > 0){
move = false;
GetComponent(NavMeshAgent).Stop();
animation.Play("idle");
}
if(health <= 0){
die();
}
}
I want hurt become true so the animation damage can run.