A* Pathfinding Project

Recast graph - exclude ground under houses


We’ve got a big city that’s essentially one big plane for the “streets” and a bunch of cubes that mark houses. I want to build a recast graph based on the streets. For somewhat large houses, though, a graph shows up inside of them, as the ground in there is large enough to allow a piece of the recast graph to show up.

Now, I can fix this by setting a really huge region size (4000 manages to exclude all the houses), but that seems hacky. Is there some better way to say “don’t consider anything inside of this box as a walkable surface”?

RecastMeshObj with Area type set to “Unwalkable Surface” prevents graphs from showing up on the roofs, but not inside the houses. I could create a plane on the floor and then later delete it, but I want to check if there’s something built-in I’m missing.


Reply to self: Setting a large Walkable Height value fixes this. That prevents underpasses, but this solution is very workable.


Have you tried putting a box collider marked as unwalkable inside the house where the space is?


I haven’t. That would work, but we have a lot of houses, and I’d rather avoid the clutter. I’d also have to teach the level designer to place out the box colliders, and I kind of want moving houses around be minimal work, so the process for the designer is as smooth as possible.

The houses all have an editor script already, so I could make that script create and then destroy the box colliders when the recast bake happens. Or the script could simply hook into the build process itself and do something like what the RecastMeshObject is doing.

I was looking for a way to do this that’s a bit more lazy, since we’re prototyping and I don’t want to go too deep into coding up solutions. Having a large walkable height was exactly the lazy I need. Now my 2 meter tall npcs need 20 meters of space above them to walk, but it works for our use case.


Most reasonable solutions have been mentioned already, so I cannot add much. I would just want to add that I have an experimental branch where colliders (except mesh colliders) can be treated as solid instead of hollow as they are now. I could share this branch with you if you want, but I am not sure if it would solve your problem. It depends on if you have colliders on the boundings already.

This is probably the easiest solution.


@aron_granberg has that experimental feature (colliders treated as solid instead of hollow) been implemented in the current version, and if so how could I activate it during the scanning?