Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

NavMeshSurface ignores NavMeshModifiers

Discussion in 'Navigation' started by Lork, Mar 12, 2020.

  1. Lork

    Lork

    Joined:
    Jul 12, 2013
    Posts:
    72
    I've tried Modifiers, Modifier Volumes, marking the objects as navigation statics, not marking them as such, and all sorts of things I can't be bothered to list. No matter what I do, NavMeshSurface treats these objects as if they didn't have the Modifiers on them.

    In this screenshot the pink objects have Modifiers on them, intended to mark those areas as non walkable. As you can see, NavMeshSurface treats them as if they were a walkable surface regardless.

     
  2. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    184
    Hi,

    Is it in hierarchy (some one on upper level have other modifier)? Are you using physics or geometry bake option?
    Try to bake it from NavMeshSurface component instead of unity
     
  3. Lork

    Lork

    Joined:
    Jul 12, 2013
    Posts:
    72
    There's no NavMesh anything above the Modifiers in the hierarchy. I'm using collider based, but I tried switching to render based and it didn't change anything. I'm already using NavMeshSurface, hence the thread title.

    I wish I could use the built in system because it actually acknowledges geometry marked as non walkable, but I need to be able to bake at runtime.
     
  4. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    184
    NavMeshSurfaces uses the same Unity.AI API as Navigation System, so it should be the same.
    Try to debug it on line 272 NavMeshSurface.cs to find out does objects in markup
    Code (CSharp):
    1.         List<NavMeshBuildSource> CollectSources()
    2.         {
    3.             var sources = new List<NavMeshBuildSource>();
    4.             var markups = new List<NavMeshBuildMarkup>();
    5.  
    6.             List<NavMeshModifier> modifiers;
    7.             if (m_CollectObjects == CollectObjects.Children)
    8.             {
    9.                 modifiers = new List<NavMeshModifier>(GetComponentsInChildren<NavMeshModifier>());
    10.                 modifiers.RemoveAll(x => !x.isActiveAndEnabled);
    11.             }
    12.             else
    13.             {
    14.                 modifiers = NavMeshModifier.activeModifiers;
    15.             }
    16.  
    17.             foreach (var m in modifiers)
    18.             {
    19.                 if ((m_LayerMask & (1 << m.gameObject.layer)) == 0)
    20.                     continue;
    21.                 if (!m.AffectsAgentType(m_AgentTypeID))
    22.                     continue;
    23.                 var markup = new NavMeshBuildMarkup();
    24.                 markup.root = m.transform;
    25.                 markup.overrideArea = m.overrideArea;
    26.                 markup.area = m.area;
    27.                 markup.ignoreFromBuild = m.ignoreFromBuild;
    28.                 markups.Add(markup);
    29.             }
     
  5. Lork

    Lork

    Joined:
    Jul 12, 2013
    Posts:
    72
    Debug.Log confirms that the objects are being collected for markup.

    And it's definitely not the same! With the old system I can mark any object as a navigation static and set it to non walkable without the need for a NavMeshModifier component and it'll be reflected in the navmesh the next time it's baked.

    Only NavMeshSurface requires the Modifier components. I assume those components are supposed to do essentially the same thing that the old system did under the hood, just in a component instead, but they're currently not working.
     
  6. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    184
    Hi,

    Check "sources" on line 351. If object is there and still no affect on navmesh, consider to share small part of project
    Code (CSharp):
    1.             AppendModifierVolumes(ref sources);
    2.  
    3.             return sources;
     
  7. Lork

    Lork

    Joined:
    Jul 12, 2013
    Posts:
    72
    The objects are all still there at that point.

    I tried making a test project with only NavMeshComponents, RealtimeCSG, and a cut down version of the level geometry (created with RCSG) and the navmesh baked correctly, taking all of the Modifiers into account.

    Doing the exact same steps in my real project (Start a new scene, make a plane with a NavMeshSurface, drop in the level prefab, bake) results in the issue. I tried adding more Modifiers to the scene and bizarrely enough, some of them worked, seemingly arbitrarily.

    In this screenshot I have 6 Modifier objects selected, all of which have identical components on them. Yet one of them is treated by the navmesh as if it didn't have a Modifier component on it.


    I've also noticed that if I drop my level prefab into one of the NavMeshComponents example scenes and bake a new navmesh, it works as it should. If only I could reproduce that in my existing or newly created scenes!
     
unityunity