Search Unity

Resolved NavMesh does not connect with indoor spaces

Discussion in 'Navigation' started by MinhocaNice, Jul 19, 2022.

  1. MinhocaNice

    MinhocaNice

    Joined:
    May 3, 2020
    Posts:
    249
    I am making a FPS game and using the NavMesh system for the enemies in the game. For some reason, the NavMesh does not connect the outer NavMesh with the indoor areas of the map, even when they are clearly open enough for the NavMesh to scan them. This makes so the enemies are unable to chase the player when they go inside any of these structures. Here are some images that show what is happening:

    upload_2022-7-19_19-34-15.png

    upload_2022-7-19_19-35-7.png

    upload_2022-7-19_19-37-27.png

    This happened with all structures in the map except the following. My theory is that this one worked because it lacks a floor collider, making the NavMesh understand there is a clear path underneath it.

    upload_2022-7-19_19-38-42.png

    Another smaller issue that might be related is that the NavMesh is for some reason loading on top of the leaves of these trees, as the following image shows. I have no idea why this happens, as there are no colliders on the leaves.

    upload_2022-7-19_19-41-21.png

    I tried multiple different configurations for the NavMesh such as decreasing the voxel size, using the HeightMesh and changing the size of the NavAgent, and nothing worked. Again, my theory is that it had to do with the floor of those buildings making the NavMesh believe they have no way to get in, but that is very odd considering how it loaded on top of those trees without a single collider there. Can someone help?
     
  2. Inxentas

    Inxentas

    Joined:
    Jan 15, 2020
    Posts:
    278
    Regarding the trees: are you sure your selected the navmeshsurface to bake based on colliders and not meshes? Because that is one option I can think of that would make certain surfaces of the tree to be eligable to be used for baking. This might also affect your floor issues, step height should take care of slight elevations.

    Also, I have experienced that when I bake and then disable the mesh, the navmesh is there but drawn ever so slightly below a weird angle. So if you bake and them temporaily disable the buildings you can see whether this is the case for you. But I really suspect you're baking in meshes mode and this causes most of your issues.
     
    MinhocaNice likes this.
  3. MinhocaNice

    MinhocaNice

    Joined:
    May 3, 2020
    Posts:
    249
    I thought about that but I haven't seen that setting anywhere. Where do I bake it based on colliders instead of meshes?
     
  4. Inxentas

    Inxentas

    Joined:
    Jan 15, 2020
    Posts:
    278
    The NavMeshSurface component. It has a few options that you can change.

    Agent Type <-- by default a standard humanoid. You can have multiple types.
    Collect Objects <-- by default it collects all. You can limit what objects are collected.
    Include Layers <-- by default every layer is included. Perhaps put trees on their own layer?
    Use Geometry <-- by default it will "render meshes", but you can also pick "physics colliders".
     
  5. MinhocaNice

    MinhocaNice

    Joined:
    May 3, 2020
    Posts:
    249
    I don't see such component... What version of Unity are you talking about? I forgot to say that I am using the LTS Unity 2020.1.14f1 Personal, where the NavMesh is set inside a Navigation tab that does not include the options you showed (except Agent Type):
    upload_2022-7-26_21-54-55.png
     
  6. MinhocaNice

    MinhocaNice

    Joined:
    May 3, 2020
    Posts:
    249
    Ah I see, you were talking about the component workflow. I didn't install that package, I used Unity's built in NavMesh system. I will install it and see if the added options fix these issues.
     
  7. MinhocaNice

    MinhocaNice

    Joined:
    May 3, 2020
    Posts:
    249
    The NavMeshComponent package is great, and worked much better than the built-in NavMesh system. I was able to fix both problems described here baking the NavMesh with it instead of the built-in system. I will use it from now on.
     
    Inxentas likes this.
  8. Inxentas

    Inxentas

    Joined:
    Jan 15, 2020
    Posts:
    278
    Ah, nice! Sorry, I tend to jack that package in from git everytime I even plan on using any NavMesh stuff. Glad it offered the solution you were looking for!
     
    MinhocaNice likes this.