NavMeshAgent: get closest GameObject to destination

153999-path.png

“E1” and “E2” are enemies that walk on a NavMeshSurface from the yellow dot to the green dot.

I need to find the enemy that is closest to the green dot, based on the path. If i use “Vector3.Distance()” it would give me E2 as result, cause its the shortest linear distance.

But i need something that gives me E1 as result.

I hope you get what i mean, english isn’t my native language :slight_smile:

This may help to your question.

https://forum.unity.com/threads/getting-the-distance-in-nav-mesh.315846/