Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[SOLVED] Bots run in circles if Navigation Layers are checked

Discussion in 'Navigation' started by Steve-of-Construction, May 29, 2015.

  1. Steve-of-Construction

    Steve-of-Construction

    Joined:
    Jan 26, 2013
    Posts:
    67
    Problem: bots don't walk to their destination but run in circles at spawnpoint.

    This happens just if the NavMesh Walkable has a selection of Nav-Layers, ie.
    - Default true
    - Jump true
    - Not Walkable false

    But if the NavMesh Walkable is set to 'Everything' the bots do their job fine.

    As soon as the Agent is set to Not Walkable -false- he won't move to it's target.

    My terrain uses 'Default' for navigation, but there are some 'Not Walkable' Areas where the bots shouldn't walk through.

    Any ideas?
    (Unity 4.6.5f1)




    Code (csharp):
    1.  
    2. #pragma strict
    3.  
    4.  
    5. var target : GameObject;              // is set manually in editor
    6. var agent : NavMeshAgent;
    7.  
    8.  
    9.  
    10. function Start () {
    11.     agent = GetComponent(NavMeshAgent);
    12. }
    13.  
    14.  
    15. function Update () {
    16.     if(target){
    17.         agent.SetDestination(target.transform.position);
    18.     }
    19. }
    20.  
     
  2. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    That sounds very odd - and i cannot repro that behaviour here.

    That said - setting 'Not Walkable" to false should have no effect - since there's no navmesh with the area type "Not Walkable" - so whether that particular value is on or off on the agent shouldn't matter.

    still - plz report a bug that's reproducing the unexpected behaviour - i'll have a look
     
  3. Steve-of-Construction

    Steve-of-Construction

    Joined:
    Jan 26, 2013
    Posts:
    67
    Thanks for help!

    Now I'm totally confused.
    I made a new project to create a small package (my project has >9 GB)

    There is a very basic scene with terrain, walls, target and the AI-enemy with NavmeshAgent and the script.
    NavMesh done, but the AI won't move at all.

    Either I'm doing something terribly wrong or my Unity is damaged?
    Can someone please check if the capsule in this unitypackage is moving?
     

    Attached Files:

  4. Steve-of-Construction

    Steve-of-Construction

    Joined:
    Jan 26, 2013
    Posts:
    67
    Though a target is set Mr. Roboto seems to make a path to himself in this sample project.
    So he don't move at all. :confused:

    In my large project it sometimes hasPath and sometimes not.
    It looks like a very moody thing and I can't figure out why this happens.

    Is it possible that there are cache files or anything else that has effect on the NavMeshAgent?
    Maybe any imported Asset from the store?
     
  5. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    For the attached example/package: it seems the target is too far off the ground - the SetDestination call returns false.
    Moving the target down so it's closer to the ground makes the agent move on start (SetDestination returns true)
    - I dont see any effect of turning on/off the "Not Walkable" flag on the agent. I think you must have something else going on in that project of yours
     
  6. Steve-of-Construction

    Steve-of-Construction

    Joined:
    Jan 26, 2013
    Posts:
    67
    Jakob you pwned my day :D

    Agents won't move if the target is too far off the ground.
    This is the same in my project - the targets are flags and these are of course not on the ground.

    Thanks a lot!
     
  7. lufactus

    lufactus

    Joined:
    May 31, 2020
    Posts:
    1
    I just solved it setting stoppingDistance anything higher than 0.
     
  8. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Best necro ever...