Get the cost between 2 points

Hello ,
I have mulitple waypoints in my level, i need to find which one i can get to with the lowest cost, is there any function that return the cost or the distance between 2 points ?


If you want to find the path to the closest of a number of target points, then you might be interested in the seeker.StartMultiTargetPath method.

Otherwise you can define a method like this

public float Distance (Vector3 a, Vector3 b) {
     ABPath path = seeker.StartPath(a, b, null);
     // Calculate the length of the path. This is only the same as the cost if you are not using penalties in your graph.
     // If you are not using penalties this will work well
     return path.error ? float.PositiveInfinity : path.GetTotalLength();

Hi Aron Thanks for your reply, i’ll try the StartMultiTargetPath method, but i tried before to use path.BlockUntilCalculated(); but i couldn’t find it in the ABPath or Path class, is it a new function added in a newer version ? my current version is 3.8.6 .
Thanks again


Yes, but it exists in 3.8.6 using a different name. I renamed it in 4.x to make the behavior of it more obvious.
You can use


which is equivalent to


okay Thanks again :slight_smile: