Search Unity

NavMesh: best way to mark areas not-walkable when using single-mesh objects

Discussion in 'Navigation' started by Kurt-Dekker, Sep 11, 2021.

  1. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    I like to keep my buildings all as one mesh (See picture).

    What is the best way to mark (for example) the rooftops as not walkable?

    The best way I have found is to put a scaled-up cube there, mark it not-walkable, bake the mesh, then hide the cube's MeshRenderer.

    This seems tedious... is there any way I can just leave ONLY the invisible collider up there as the blocker, not leave the MeshRenderer on during bake? I can always make a runtime mesh hider script and put it on there but this also seems like a hack.

    Q: How to block areas from being walkable WITHOUT using a separate MeshRenderer?

    no_walk.png
     
    valarnur likes this.
  2. Kurt-Dekker likes this.
  3. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    Talking about
    ModifierVolumes
    about making things non walkable. Is there a way to make a
    ModifierVolumes
    affect one navmesh but not affect another?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    Thanks Lurk for the pointer... that is what I want exactly.

    BUT! I went down a deep and annoying rabbit hole for a while though because I could not get the volume to work.

    I even created projects in 2020, 2018 and even Unity5, using the appropriate branch of the code in all cases.

    In all cases it absolutely WOULD NOT cut a hole in my NavMesh. I baked and re-baked, double-triple-checked the static-ness, the visual overlap, the shape, the flags (Not Walkable) and everything.

    It absolutely would NOT cut holes the way I wanted.

    Turns out this external "Component workflow" stuff ONLY affects NavMeshSurfaces, which is one of the new components installed from github. Each instance of that stands up a fresh navigable surface, and THOSE pay attention to these volumes when baking.

    I have suggested to Unity that they represent this clearly in bold at the top of the documentation.
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    I think maybe it is done at the agent level, which is a bit counter-intuitive. I think? You make a navmesh for each agent, then make your volume affect only one type of agent.
     
    Guedez likes this.
  6. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    wouldn't work for my use case then. I need to split regions of my map into multiple navmeshes because they are so big the NavMesh class just gives up and don't give me an path otherwise, even if it does actually exists...
     
    Kurt-Dekker likes this.