Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug NavMeshAgent repeat forward-backward at some point, never arrive destination

Discussion in 'Navigation' started by dongch007, Mar 15, 2023.

  1. dongch007

    dongch007

    Joined:
    Jan 8, 2014
    Posts:
    37
    See video

    I disabled rotation so role not rotate backward in this video.
    NavMeshAgent.SetDestination return true.
    NavMeshAgent.path looks right before it repeat.
    When role move backward, NavMeshAgent.remainingDistance is infinite.
    NavMesh look like this, center road's cost is 1 and other walkable is 3
    upload_2023-3-15_19-27-30.png
    upload_2023-3-15_19-32-20.png

    Is there setting wrong or this is a bug?
    Unity version is 2020.3.46, same issue in 2021.3.18
     
    Last edited: Mar 15, 2023
  2. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    That is usually the case if your "destination" is slightly above or underneath the Agent, so try to check your destination if it is right on the track
     
  3. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    656
    Try setting stopping distance on your agent to... say ... 1 to test.
     
  4. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    Yes, in addition to my answer, that one here is right.
    If you dont want to do the part i have mentioned, try to increase the stopping distance
     
  5. dongch007

    dongch007

    Joined:
    Jan 8, 2014
    Posts:
    37
    Thanks, but change stopping distance have no effect.
    The destination is not in screen, it's far away. It's calculated by NavMesh.SamplePosition.
    The issue point is just one corner in NavMeshAgent.path.
     
  6. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    656
    Ohh, i think i see the debug line way up further ahead of you. Yea, thats definitely not a stopping distance issue. Hmm, im at a loss atm.
     
  7. dongch007

    dongch007

    Joined:
    Jan 8, 2014
    Posts:
    37
    I upload a sample project. Play and see role capsule's movement
     

    Attached Files:

  8. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    So i did download your Project and for me it does work after modifying the NavMeshAgent settings.

    - Modify NavMeshAgent settings
    - Rebake Area
    - Start

    he also reaches the destination
     

    Attached Files:

    • 2.PNG
      2.PNG
      File size:
      290.6 KB
      Views:
      65
    • 3.PNG
      3.PNG
      File size:
      266.6 KB
      Views:
      62
  9. dongch007

    dongch007

    Joined:
    Jan 8, 2014
    Posts:
    37
    Hi, can I know what settings changed?
    I tried many versions 2020.3.42/2020.3.46/2021.3.16/2021.3.18/2021.3.19/2022.2.9, it all has the issue.The only difference is maybe not at the same corner. (stopping distance set to 1)
    Maybe this relates to the platform, My platform is windows10 and my CPU is intel8400/intel10400.
     
  10. dongch007

    dongch007

    Joined:
    Jan 8, 2014
    Posts:
    37
    Ok, I tried again. If use old data in this project, which was baked in 2020, all versions will have issues.
    After the 2021 rebake navmesh sometimes this issue disappears, but sometimes still has.
    It's so weird.
     
  11. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    i did change max slope and step height up in value (just for the sake of test) and it works every time.

    I do not believe that it depends on the hardware you use since unity is/should be in terms of development hardware independent (in terms of functionality obv.)

    My specs:

    - Win 10
    - 1080Ti Extreme Edition 12GB
    - Intel 8700K
    - 16GB RAM
     
  12. dongch007

    dongch007

    Joined:
    Jan 8, 2014
    Posts:
    37
    change bake setting will change the NavMesh, the issue may disappear in this case. I used to change voxel size/agent height/step height before, issue disappear in this case but appear in another case, and case not easy to find.
    I'll update our game to 2021.3 to do more tests. But I'm really sure it's a problem in 2020.3.
     
    Last edited: Mar 17, 2023