void Update() { if (nav != null && !(nav.pathPending)) { if (!(Vector3.Distance(nav.destination, nav.transform.position) <= nav.stoppingDistance)) { enemyAnimationController.HandleAnimation("EnemyForward"); } if (!hasInteracted) { targetLastPosition = currentTarget.transform.position; if (nav.destination != targetLastPosition) { MoveToInteraction(); } // Key to this check is that stoppingDistance is set to 0 when current destination in not interactable; hence those "clicks" won't call Interact() if (nav.remainingDistance <= nav.stoppingDistance) { if (Time.time > nextAttackTime) { PerformAttack(); nextAttackTime = Time.time + attackInterval; //hasInteracted = true; } if (!nav.hasPath || nav.velocity.sqrMagnitude == 0f) { enemyAnimationController.HandleAnimation("EnemyIdle"); } } else { nextAttackTime = Time.time + attackInterval; } } } }