public NavPoint GetNextPoint(Vector3 position) { if (points.Count > 0) { NavPoint next = points[current]; if (!next.AtPoint(position)) { return(next); } else if (!AtDestination()) { if (points.Count - 1 == current) { return(null); } current++; return(points[current]); } } return(null); }
public void CheckRoute(Vector3 destinationPosition) { // if (waitingForRoute) { // Debug.Log("Waiting"); // return; // } if (route == null) { Destination = destinationPosition; atDestination = false; } else { current = route.GetNextPoint(transform.position); if (current == null) { route = null; return; } atDestination = route.AtDestination(); } }
/// <summary> /// Sets the current route, and sets waiting for route to false, allowing the agent to make new route requests /// </summary> /// <param name="route">The new best route to the destination</param> private void SetRoute(Route route) { waitingForRoute = false; this.route = route; destinationPoint = route.points.Last(); }