Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Upgraded Unity, now getting "Failed to create agent because it is not close enough to the NavMesh"

Discussion in 'AI & Navigation Previews' started by BenSizerRovio, Oct 9, 2017.

  1. BenSizerRovio

    BenSizerRovio

    Joined:
    Sep 25, 2017
    Posts:
    12
    I was using 2017.1.1f4 (or whatever the latest 'official') version is, and navigation was working fine, but since it crashed about 10 times daily I upgraded to the latest patch version, 2017.1.1.p4.

    Now, the navigation doesn't seem to work: I get told "Failed to create agent because it is not close enough to the Navmesh". The navmesh still exists, I tried rebuilding it, but nothing works. I can get the character's starting point within centimetres of the navmesh below it but I still get the "not close enough" error.

    Anyone know what's going on? I'll have to revert to the 'stable' version until I can resolve this. (It does work as usual once I revert.)
     
    Last edited: Oct 9, 2017
  2. aaforcebox

    aaforcebox

    Joined:
    Dec 13, 2016
    Posts:
    1
    I was having the same issue after upgrading from 2017.1 to 2017.2.0f3. The problem was solved after reviewing all the properties of agents and navmesh (I think the height and step-height of Humanoid agent were different from the right values) and baking the navmesh again.
     
  3. pondo

    pondo

    Joined:
    Mar 22, 2015
    Posts:
    7
    Anyone have a resolution to this problem? I'm having the same issue after the upgrade. Almost ready to go back to the earlier version...

    @aaforcebox:How did you you solve it by reviewing nav agent settings?
     
  4. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,248
  5. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    If you are sure your mesh is fine but you're still getting this error, then try those two things:
    1) Delay the spawning of your unit / navAgent until 2frames after the game has started / the scene has finished loading.
    2) When activating your navAgent try this:
    Code (csharp):
    1.  
    2.             _navAgent.enabled = false;
    3.             _navAgent.enabled = true;
    4.             _navAgent.Warp(transform.position);
    5.  
    I don't know why but this reliably solved the issue for me in all the scenarios it happened.
     
    astracat111 and BenSizerRovio like this.
  6. BenSizerRovio

    BenSizerRovio

    Joined:
    Sep 25, 2017
    Posts:
    12
    I filed a bug report, but the QA person didn't bother to read it properly and closed it. He said:

    "Unfortunately, this sounds more of a feature request than a bug. NavMesh itself seems to be working as intended.
    Unless it's your specific occasion, error does depend on the distance between NavMesh and NavMeshAgent (throwing an error starting at 9 units)."


    The object is not even ONE unit away and I get this error. Very angry at their QA right now.
     
  7. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Just reply telling them that the object is in fact one unit away, not 9, no point in getting angry.
     
  8. BenSizerRovio

    BenSizerRovio

    Joined:
    Sep 25, 2017
    Posts:
    12
    I did. But QA shouldn't close issues without reading them.
     
  9. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,248
    Your expecting too much of unity QA, from what I hear they are always doing this sort of stuff.
     
  10. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Open another issue with a very small scene that clearly shows the problem. Maybe someone else will read it then :p
     
  11. hanbekov

    hanbekov

    Joined:
    Apr 1, 2017
    Posts:
    6
    I too get warning "Failed to create agent because it is not close enough to the Navmesh". A see - prefab spawn similar NavMesh. 0_0
    Then I use NavMesh.SamplePosition for get real NavMesh point. But no effect.
    And I find root of this error - unHumanoid agent type!
    I set agent type to Humanoid and script worked perfectly, without warning.
    But what will done? I need different unHumanoid agents type!
     
    muammar_a_tq likes this.
  12. BenSizerRovio

    BenSizerRovio

    Joined:
    Sep 25, 2017
    Posts:
    12
    Sometimes the agent settings for that type don't match the ones set on the navmesh itself. I don't know why that would cause this problem, but sometimes it does. HOWEVER that is not the problem I have. I have Humanoid for everything.
     
  13. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,248
    try using navmesh agent warp and warp to same location
     
  14. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    666
    This code here actually worked for me, solving the problem completely. Unfortunately, there's no way that I can shut off or get rid of the initial "failed to create navmeshagent" debug error now. I'll just have to live with it.

    For me it's instantiating a prefab with a navmeshagent that made it so that it couldn't create it. Any time one of my objects that needs to be instantiated is created now I get the problem.
     
  15. laessnb

    laessnb

    Joined:
    Jun 10, 2014
    Posts:
    92
unityunity