Search Unity

Unity 5.6 Navigation System

Discussion in 'Navigation' started by VegetarianZombie, Apr 21, 2017.

  1. VegetarianZombie

    VegetarianZombie

    Joined:
    Jul 16, 2013
    Posts:
    14
    Hello,

    I've been getting used to new changes to the Navigation system in Unity 5.6. Unfortunately, the manual or documentation hasn't been updated. I'm actually teaching this so any help would be greatly appreciated.

    First, in the Navigation window, there is an Agents tab and a Bake tab. One is for a bake agent and the other is for non baked agents? I see that in the Nav Mesh Agent, I must select my agent type. Does the baked agent influence this in any way?

    Second, In my project, I created a new agent type, gave him properties, and in the subject GameObject, I set the Agent Type to be this newly created Agent Type. Upon setting a destination in code, I got back an error. Using humanoid as the agent type, everything worked fine. I then copied the values from the Humanoid agent type to my new agent type, and it failed to work. Is there additional configuration to a custom agent type to get it to work?

    Again, any help is appreciated.

    Thanks!
    Brian
     
  2. superdupergc

    superdupergc

    Joined:
    Jun 21, 2013
    Posts:
    28
  3. Tyrathect

    Tyrathect

    Joined:
    Jul 10, 2012
    Posts:
    38
    Bumping

    Have you guys figured this out yet? What does the "Agents" tab do?
     
  4. superdupergc

    superdupergc

    Joined:
    Jun 21, 2013
    Posts:
    28
  5. Andreu-Accensi

    Andreu-Accensi

    Joined:
    Feb 5, 2015
    Posts:
    18
    I tried this and that's the case.

    Though for my needs I had to do this at runtime and when I set the agentTypeID property at runtime it always fails with a warning saying "Invalid agent type".

    Similarly I wanted also to create NavMeshAgents at runtime but the navmesh component does not even have a property to set the agentType through a script (despite the property is visible in the inspector)... so right now the only way to do this if u have more than 1 agent type at runtime is to actually set this values in prefabs with the right agenTypeID and instance them at runtime.
     
  6. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    the agentTypeID should be exposed to API in the latest release of 5.6 (if not it's on its way).
     
  7. Andreu-Accensi

    Andreu-Accensi

    Joined:
    Feb 5, 2015
    Posts:
    18
    I believe I have the latest release. I have 5.6.0f3. I'll explain myself better with some pictures as maybe I'm doing something wrong.

    So what I found is that if I add a 2nd agent type. Then when at runtime I try to set the agentTypeID of the NavMeshSurface (the one you can get from GitHub) I get this Warning you can see below saying "Agent Type invalid." (In this case I tried to set it to 1 as Humanoid was 0. Maybe is a wrong assumption).
    NavMeshSurface.png


    And in the other hand when working with the NavMeshAgent (this one comes already built in) the agent type property seems not to be exposed through code (thought is visible in the inspector/editor) so it cannot be set at runtime at all.
    NavMeshAgentExposed.png
    VS
    NavMeshAgentInspector.png
     
  8. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    The agentTypeID will most likely not be 1 for the 'TEST' agent type. To obtain type id from index do smth along these lines:

    Code (csharp):
    1. for (int i = 0; i < NavMesh.GetSettingsCount (); ++i)
    2. {
    3.   var settings = NavMesh.GetSettingsByIndex (i);
    4.   Debug.Log ("Index : " + i + " Agent Type ID : " + settings.agentTypeID);
    5. }
     
  9. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
  10. Andreu-Accensi

    Andreu-Accensi

    Joined:
    Feb 5, 2015
    Posts:
    18