Preventing creation of graph portions within mesh colliders

  • A* version: 5.3.1
  • Unity version: 2022.3.51

Hello, I’m posting this in the Beginner Questions section because I’m assuming it is one, we’re having issues with Recast graphs and mesh colliders in a game with lots of building and house models that end up with small graph portions within themselves. An illustration is needed here, so allow me to share this screenshot from the Recast 3D scene which has the same issue :

As you can see in the upper half of the picture, various graph portions are within buildings. So my question would be how to prevent that ? I know that in this demo scene the character is moved through clicks and raycasts, so he can’t be ordered to go onto these portions since they can’t be reached by raycast, and about 4 years ago I made a script to evaluate if a path was possible before sending the agent there, so I know that’s a possibility, but I would be really interested in removing these unwanted pieces of graph.

Is there a possibility to create no-go areas with Recast graphs, or is there a parameter to prevent the creation of such portions in the Astar Path component ? One last thing I can add is that I noticed box colliders prevented the issue and are apparently more reliable than mesh colliders. When putting a simple cube with a box collider and another one with a non-convex mesh collider in the same scene with a Recast graph, only the second one has a blue piece of graph in it.

Thank you very much in advance for any help you can give on this.

Hi

Convex colliders will by default be treated as solid, and prevent any navmesh inside of them.

Non-convex mesh colliders cannot be treated the same way, because it’s not always possible to know what is inside and what is outside them, they are just a polygon soup. However, you can attach a RecastNavmeshModifier component to the object with the mesh colliders and manually check the “Solid” option. That will make it use a best-effort attempt at figuring it out.

1 Like

Wow, thanks for the lightning-fast answer ! This RecastNavmeshModifier component sounds exactly like what we need, thank you ! I should write a 5 star review for your asset someday :smiley:

1 Like

That would be most appreciated :blush: