Search Issue Tracker

Won't Fix

Votes

0

Found in

2017.1.0f3

Issue ID

931624

Regression

No

[NavMeshComponents] Picking another NavMesh Agent as destination while it is on a NavMesh "island" gets Agent stuck in place

AI Navigation

-

Steps to reproduce:
1. Open attached Unity Project "SheepTagNavmesh.zip"
2. Load Scene "Testing"
3. Enter Play mode
4. Select a werewolf/shepherd character with the Left Mouse Button.
5. Find the sheep enclosed by yellow buildings in the upper-right corner.
6. Right Mouse Button click on the enclosed sheep.

Expected result: the NavMesh Agent finds the closest spot to a destination it can reach and moves there
Actual result: the NavMesh Agent gets stuck in place (see attached gif "NavMeshComponentsBug")

Reproducible with: 2017.1.0b8, 2017.1.0f3, 2017.2.0b3
Note: not tested on earlier versions because the version of NavMeshComponents extension used in this project is incompatible

  1. Resolution Note:

    A workaround was provided for the user with the following commentary from the development team:

    navAgent.destination = attackTarget.bounds.ClosestPoint(transform.position).SnapToSingleGrid();

    sets a new destination for the agent in each frame. Because the destination is on a NavMesh island and it doesn't match the end position of the latest obtained path (at the outer edge of the houses) a new pathfinding request is created every time. It will take more frames for it to complete, due to the complexity of the NavMesh (caused in this situation by adding many of those farm buildings). During that time `hasPath` returns true but the path is not the final and correct one. That is probably the underlying problem we will have to fix. I cannot give a time estimate for it now.

    A workaround would be to use navAgent.CalculatePath() instead of navAgent.destination but this has the drawback that the path is computed synchronously in the same frame, whereas setting the destination runs asynchronously and it splits the operations across several frames.

    var targetPosition = attackTarget.bounds.ClosestPoint(transform.position).SnapToSingleGrid();
    var path = new NavMeshPath();
    navAgent.CalculatePath(targetPosition, path);
    navAgent.SetPath(path);

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.