Detecting Whether Specific Area Of Navmesh Is Walkable.

I’m aware of the NavMesh.SamplePosition function but I’m wondering if there’s a way to determine if the entirety of a collider is in or over a specific area (non-navigable) of a navmesh.

For instance, when OnCollisionEnter is called you can get the position it collided and use SamplePosition on this position. But this is not ideal because the object may not be colliding with the terrain mesh but rather on top of it.

What I need to do is determine whether or not an entire collider is within a walkable area.

Preferably without doing something hackish like attaching a navmesh agent with a radius to match the collider and then checking the path.

I don’t think that’s possible, for one simple reason… Colliders are 3D volumes, whereas NavMeshes are essentially 2D surfaces in 3D space.

So, it’s like trying to check if an apple is entirely within a flat sheet of paper. It can’t possibly be.

NavMesh.SamplePosition + NavMesh.Raycast

I didn’t found any other solution. Combining results from SamplePosition() and Raycasting between those points should give you approximate result. If navmesh structure is very differential then it will fail but for simple navmeshes this might be good enough.