public void ProcessMover() { if (unitControl.IsDead() || unitControl.IsStunned() || unitControl.IsAttacking()) { return; } if (unitControl.HasEnemy()) { Transform enemy = unitControl.GetCurrentEnemy().transform; float minDist = Mathf.Max((unitAttack.attackRange / 2), 2); if ((transform.position - enemy.position).sqrMagnitude > minDist) { MoveTowardsTarget(enemy.position); } else { animator.SetBool("isRunning", false); } } else { Vector3 goalPos = homePosition; goalPos.y = transform.position.y; if ((transform.position - goalPos).sqrMagnitude > 1) { MoveTowardsTarget(goalPos); } else { animator.SetBool("isRunning", false); } } }