NavAgentID with NavMeshQuery

I need clarification on using the NavMeshSurface and the experimental API with different agents. It seems as if only the Humanoid settings are ever saved, using a different AgentID with NavMeshQuery does not yield any results. I am pretty sure this is broken, but there are no signs that it is going to be fixed. Feedback from the team working on Navigation would be greatly appreciated.

Doing this, only Humanoid is printed regardless of what other Agents exist. Everything else has default values, with no name.

for(var i = 0; i < 15; i ++){
    Debug.Log(NavMesh.GetSettingsNameFromID(i));
    Debug.Log(NavMesh.GetSettingsByID(i).agentRadius);
}

I am trying to implement a second NavMesh for vehicle actors and this feature is integral for making it work.

EDIT: This has been brought to attention but no word on a fix in progress.

It’s not broken it’s just not very intuitive as to how it works.

You have a list of defined agent types in the editor. You are treating the index as if it’s the Id, but that’s not how it works. They chose to hardcode the first agent type as id 0, which also happens to be at index 0.

So other then the first agent type you need to lookup the id like so:

NavMeshBuildSettings navSettings = NavMesh.GetSettingsByIndex(1);
int agentTypeId = navSettings.agentTypeID;
2 Likes

Thanks, I will try this.

I get an exception “The start location doesn’t belong to any active NavMesh surface.” despite the position being queried clearly living on the surface and the extents being large. Any tips? I assume you have been able to get this working yourself.

I can confirm that this works, updating unity and using the appropriate version of navmeshcomponents from github fixed my issue.