void Update() { timer += Time.deltaTime; if (timer >= timeBetweenAttacks && playerInRange && enemyHealthHU.getHealth() > 0) { Attack(); } if (playerHealthHU.getHealth() <= 0) { anim.SetTrigger("PlayerDead"); } }
void Update() { if (enemyHealthHU.getHealth() > 0 && playerHealthHU.getHealth() > 0) { if (body != null && body.velocity.magnitude <= 0.1f && !nav.enabled) { body.isKinematic = false; nav.enabled = true; } nav.SetDestination(player.position); } else { nav.enabled = false; } }