Search Unity

NavAgent randomly misses their destination

Discussion in 'Navigation' started by Comafly, Jan 9, 2019.

  1. Comafly

    Comafly

    Joined:
    May 30, 2014
    Posts:
    87
    I've been implementing a simple AI system in to my current project, where the NPC will be given a destination on the NavMesh, they will walk to the destination, pause for a random amount of time, and then move on to a new random position.

    This mostly works as expected. But every now and then the NavAgent will fail to get to the destination, or will take a completely roundabout way to get there - sometimes even getting stuck by attempting to walk through gaps in the NavMesh. Video showing the issue below, the destinations represented as white spheres:

    High-res video here.



    It's very odd, because the Agent can work flawlessly for 5 minutes reaching every destination without an issue, and then just become braindead, walking in circles around their destination where they had no trouble navigating 30 seconds prior. I've debugged the NavAgent and they are receiving the location and changing their destination to the right position.

    Also, here is an image of the NavMesh, to show there is nothing funky going on there:



    I've tried all kinds of combinations of angular speed and acceleration. And the stopping distance is already at the maximum of what I'd like. I am at a loss as to what is causing this issue.

    Any help at all would be much appreciated!

    Thanks

    Brendan
     
    Last edited: Jan 9, 2019
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Woah, that's something I haven't seen before. At first it looked like the agent was searching for a path crossing as few triangles on the navmesh as possible, but when looking at your navmesh screenshot it looks like the kind of triangle clumps that typically cause this is on the other side of that thin wall he walks past.
    Question, if you use that starting point and target, can you recreate that weird walking thing consistently?
     
  3. Comafly

    Comafly

    Joined:
    May 30, 2014
    Posts:
    87
    Yep, can confirm it is 100% repeatable. I recorded another video showing the repetition and the live pathfinding.

    High-res version here.



    If I move the NavAgent to a different position, he can pathfind to that spot just fine.
     
  4. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Hmmm, you might want to bring this up to the development team through a bug report. I'm not sure how this would be caused.
     
  5. xuyennguyen

    xuyennguyen

    Joined:
    Mar 3, 2014
    Posts:
    2
    I have the same problem with you. Does anyone have a solution for it?
     
  6. sandherostudio

    sandherostudio

    Joined:
    Jan 26, 2020
    Posts:
    1
    https://forum.unity.com/threads/sim...028.385243902.1580054382-718511573.1579793430

    Try to increase acceleration. It helped me. My speed = 2 and accel = 2 and I seted accel to 10.