Pathfinding destination is on closest connection instead of closest on graph?

Hello there.
How can I calculate a path to the closest point within a graph, instead of the closest connection?
The following code we use to calculate the path for an AI.
As you can see from the image, the end position seems to be the closest connection, instead of the actual target (red gizmos), which could be much closer. Am I mis-understanding how Recast graphs work?

// Get the path
			ABPath path = ABPath.Construct(originPosition, targetPosition);

			// Start the path calculation
			AstarPath.StartPath(path, true);

			// Wait for path to be calculated
			while (path.IsDone() == false)
				yield return null;


Paths often require some sort of post-processing. The Seeker adjusts the endpoints of the path like you want using the StartEndModifier.
When you use a seeker this is done automatically. If you use the AstarPath.StartPath method directly, you can still post-process the path using a seeker by calling seeker.PostProcess(path) after the path has been calculated.

See StartEndModifier - A* Pathfinding Project

1 Like

Brilliant, thanks for the prompt reply. We are not using the Seeker component ourselves however for anyone else in the same position you can use:

			// Modify the path so that the end point is closest on graph, not connection
			StartEndModifier startEndModifier = new StartEndModifier();

And then use a similar method to Apply a funnel.

1 Like