Search Issue Tracker
Won't Fix
Votes
0
Found in
5.4.2p4
Issue ID
855522
Regression
No
Agent does not plan shortest path
How to reproduce:
1. Open attached project
2. Open scene test.unity
3. Open the Navigation window
4. Play the scene
5. Select the Agent gameobject
- Note how the navigation debug view displays the planned path to be along the edge of the path
- Moving the Agent around using the transform handles in the scene view causes the path to be recalculated into the actual shortest path
- Reproduced in 5.4.3p1 (00292ff31167), 5.5.0f3 (1d1a0b50d15c), 5.6.0a6 (af2099d5a7ac)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Nested Canvases with the same Order in Layer ignore Z position for render order when sharing parent Canvas
- ShaderGraph Material subasset loses texture reference when reimporting all assets while using a scripted importer
- Values changed on a prefab are not retained when entering Play Mode
- Shadow Caster 2D shadows partially disappear in specific spots when used with Composite Collider 2D in the Game view
- Hierarchy and Library parts in UI Builder are inaccessible when UI Builder window is resized and these elements no longer fit in the window
Resolution Note (2021.2.X):
As a performance optimization, the current implementation of the Navigation system does not guarantee that the path found towards the destination is always the shortest one (i.e. optimal). To compensate for this limitation the NavMeshAgent will try to optimize the path regularly as it moves towards its destination. Overall, this technique aims to reduce the movement of the agent to the minimum, but it does not guarantee that the reported NavMeshAgent.path will be the shortest one at any given time.
In the cases when the path found through a section of the NavMesh (the game environment) is repeatedly sub-optimal, it is recommended to slightly change the environment geometry in that area such that the NavMesh geometry improves. In turn this will increase the chances of obtaining the shortest path. The geometry of the NavMesh can produce better paths when it does not contain long, thin polygons. Please try to tweak the factors that influence the creation of such triangles. They can be: excessive detail of the obstacle geometry (at the border of the NavMesh), or a low value for the "voxel size" parameter (often used for increasing the accuracy of the NavMesh).