How to call StartPath with a list of waypoints, instead of just a start and end?


I am currently managing movement by determining a list of waypoints for the seeker to follow, and then doing a seeker.StartPath for each next one. The problem with this, is that the seeker is trying to slow down and stop for each intermediary waypoint, as if it was the end of the route.

This solution works if I increase the end reached distance, but then it stops too far from the final target. If I use CloseToDestinationMode.ContinueToExactDestination, the seeker sometimes does this weird movement at the final destination, where it is gyrating in a circular motion around the target, similar to a chicken settling down to sit on her eggs, lol. It does this for a second, then stops in a direction different from their previous heading, which looks bad. I think the ‘continue to exact destination’ is trying to move it too much there, at the end.

The reason I am determining my own waypoints is because of specific route requirements outside of Astar’s scope. Is there a way for it to not apply the “End Reached Distance” variable, which I believe is only meant for the end of a route, to each intermediary waypoint?


I think you should change the relevant parameters as the agent moves in that case. Make them different for the last waypoint.
So in a separate script you can do something like:

float slowdownTime;
void Update () {
   ai.slowdownTime = isApproachingLastWaypoint ? slowdownTime : 0;
   if (ai.reachedEndOfPath) {
       // pick next waypoint

Or something like that.

Thank you for the suggestion. I basically tried something similar, where I would check if the next waypoint was the last one or not. If so, I would customize the slowdownDistance, pickNextWaypointDist and EndReachedDistance.

The problem that arose was that seekers kept trying to follow paths from what it detected as nodes, rather than sticking to my waypoints. I am assuming that this is because I am using a grid graph, and my waypoint positions aren’t in the center of a node.

Would using a recast graph solve this?

I just tried to add a recast graph, in addition to my current grid graph, and I noticed that Unity is freezing up when I try to stop the scene. Why would the scene start up ok, but lock up on exit?

I’m not quite sure what you mean here. Think you can show a screenshot?