private void Update()
{
if (life.getLife() <= 0)
{
if (!isDieing)
{
isDieing = true;
animation.Play("Anim_Death");
dieingSound.Play();
deathParticles.SetActive(true);
Destroy(gameObject, animation.clip.length);
}
return;
}
if (navMeshAgent.isStopped)
{
state = StateAI.Attacking;
if (!animation.isPlaying)
{
animation.Play("Anim_Attack");
playerLife.decreaseLife(attackPower * Time.deltaTime);
attackSound.Play();
}
}
else
{
state = StateAI.Walking;
if (!animation.isPlaying)
{
animation.Play("Anim_Run");
}
}
}