So, we’ve been using ProBuilder to prototype our level, and we decided to use planes instead of cubes. When it came to scanning the meshes (we are not using terrains), we noticed that the scan was bleeding into some of the walls because the floor was clipping with them, even though the walls are in a layer set as unwalkable.
I searched around and found the RecastNavmeshModifier and added it to all of the walls, setting them as non-dynamic and as solid. Tested both mesh and collider. This didn’t seem to have any effect on the scanning, it still looked the same.
Image: Recast is bleeding into this wall, even though layer is Unwalkable:
We gave it the benefit of the doubt and figured that it was probably because the mesh of the walls were not “closing the gab” underneath, so the modifier didn’t have a min and max height to create its solid bounds. We then adjusted the planes to close the gab underneath and it worked, but it left us wondering if this was indeed the best solution. It feels hacky and not super reliable. Is this indeed the expected way to work with the walls?
As a bonus comment, our problem is currently that we are trying to get a random point in the recast graph for our agent to walk towards, but maybe our algorithm is wrong? Perhaps if there is a better way to get a point that is actually reachable, we can have these bleeding scanned edges and they won’t affect gameplay.
Does your wall object/planes have a single collider wrapping them? Or is the collider just the wall/the mesh? That may be what’s going on here. Show me how these walls come together if you’re still having issues with it
When I did this in my game I did this, for spawning items in walkable locations. Old code that haven’t touched in a bit- I wouldn’t copy paste this directly
for (int i = 0; i < itemsToSpawn; i++){
GridNodeBase node = graph.nodes[UnityEngine.Random.Range(0, graph.nodes.Length)];
if (!node.Walkable){
// Node not reachable, dismissing;
i--;
continue;
}
// Use the node here
}
The “solid” functionality is done by checking the min and max y coordinate of the object at each x,z cell. So it does need a bottom face as well, I’m afraid.
Sure, you can use the area field of the NNConstraint for this.
var playerNode = AstarPath.active.GetNearest(player.position, NNConstraint.Walkable).node;
var nn = NNConstraint.Walkable;
nn.constrainArea = true;
nn.area = playerNode.Area;
// Finds the closest point which is reachable from the player's position
return AstarPath.active.GetNearest(randomPoint, nn).position;