- Home /
Unity pathfinding - Comparing 2 paths?
I have a NavMeshAgent, which has multiple destinations to choose from. At the moment i am using the Vector3.Distance() to compare which destination is best to reach. The thing is, this way of doing it does not take unwalkables into consideration.
So lets say i have two calculated NavMeshPaths. Is there any way to compare the "cost" of these paths?
I am using C#.
Answer by cjdev · Jan 19, 2016 at 10:08 AM
You can use NavMeshAgent.path.corners to get a list of waypoints that the Agent will travel along on it's current heading. They are straight lines between points so you can just sum the linear distance and compare.
I actually figured that out about 10 $$anonymous$$utes ago. But yeah it works! hope it helps somebody else!
Answer by White8eard · Jan 19, 2016 at 07:46 PM
you can implement a* star by urself, navmesh also uses a* system.
http://www.redblobgames.com/pathfinding/a-star/introduction.html
Your answer
Follow this Question
Related Questions
Enlarge the NavMesh paths my player has to follow 1 Answer
is it possible to use navmesh on flying character and target ? 0 Answers
Looking forward while walking with navMeshAgent 1 Answer
Finding Closest Object Through Navmesh,Identifying Which Object Is Closest on NavMesh 0 Answers
SetDestination's and CalculatePath's Path State Return Works Too Late 1 Answer