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

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.)

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.

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?

Take a look at: https://discussions.unity.com/t/680084

Then file an issue

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:

            _navAgent.enabled = false;
            _navAgent.enabled = true;
            _navAgent.Warp(transform.position);

I don't know why but this reliably solved the issue for me in all the scenarios it happened.

2 Likes

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.

Just reply telling them that the object is in fact one unit away, not 9, no point in getting angry.

I did. But QA shouldn't close issues without reading them.

Your expecting too much of unity QA, from what I hear they are always doing this sort of stuff.

Open another issue with a very small scene that clearly shows the problem. Maybe someone else will read it then :P

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!

1 Like

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.

try using navmesh agent warp and warp to same location

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.

In case anyone is trying to figure this out later, like I was, you can only use non-Humanoid agent types if you use NavMeshSurface from the nav components here: https://github.com/Unity-Technologies/NavMeshComponents