private void Update() { UnitController unitController = (UnitController)controller; if (unitController.state == UnitState.LANING && currentWaypointId < waypoints.Length) { bool withinDetectionRange = GeometryMethods.IsWithinRange(waypoints[currentWaypointId].transform, transform, 2); if (withinDetectionRange) { currentWaypointId++; GoToWaypoint(); } } }