Search Unity

NavAgentID with NavMeshQuery

Discussion in 'AI & Navigation Previews' started by riskparitygawd, May 5, 2019.

  1. riskparitygawd

    riskparitygawd

    Joined:
    Sep 22, 2018
    Posts:
    10
    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.
    Code (CSharp):
    1.  
    2. for(var i = 0; i < 15; i ++){
    3.     Debug.Log(NavMesh.GetSettingsNameFromID(i));
    4.     Debug.Log(NavMesh.GetSettingsByID(i).agentRadius);
    5. }
    6.  
    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.
    https://forum.unity.com/threads/seams-bug-in-navmeshquery-api-with-custom-agenttype.574798/
     
  2. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    2,172
    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:
    Code (csharp):
    1.  
    2. NavMeshBuildSettings navSettings = NavMesh.GetSettingsByIndex(1);
    3. int agentTypeId = navSettings.agentTypeID;
    4.  
     
    riskparitygawd likes this.
  3. riskparitygawd

    riskparitygawd

    Joined:
    Sep 22, 2018
    Posts:
    10
    Thanks, I will try this.
     
  4. riskparitygawd

    riskparitygawd

    Joined:
    Sep 22, 2018
    Posts:
    10
    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.