The distance along a path

Is there a way to compare the overall pathfinding distances between two different paths? For example, lets assume we are using Pathfinding Service, and have multiple Computed Paths. How would this then work? Would you have to manually calculate the distances between each Waypoint, and add them all up, or is there a shorter, much more efficient way to do it?

Couldn’t you just check the Magnitudes of the Distance of the Paths & compare it to a range? (SumOfAllPathDistancesUsingMagnitude / TotalNumberOfPaths)

Not sure if this would be what you want

1 Like

That’s what I meant by manually calculating all the distances. I’m asking whether there is a property or function built in to automatically do this.

I don’t know of any built in function for this service that finds the best path. However, you can use a path finding algorithm to accomplish this.

A good pathfinding algorithm is Djikstra’s algorithm. Here is a function that finds the shortest path using it:

I don’t believe there is a built-in function for getting all of the distances, you’d need to set up your own way of doing so using some math