Recast graph generated under the terrain

Hi,

I have been testing my navmesh and was getting issues with my agent falling through the terrain. Our terrain is very large and has areas where the terrain is undulating

After some investigation I discovered that there are a lot of areas where the graph was being generated below the surface of my terrain. They are usually small and patchy but some are enough for the agent to fall through

So when the agent was then moving along the path that was generated, it would reach this section and immediately fall through the terrain. I do not have any character controllers or rigidbodys applying physics on my agent so not sure why this is happening

Is there a way to ensure the navmesh does not generate above the terrain? Or to stop the agent from falling when this happens, even if the graph is slightly below the terrain??

Any update on this?

Tried adding a box collider plus ridigbody which is helping to prevent the agent from falling below ground, however the rigidbody is causing other issues like agents randomly floating or having struggling to get over some terrain

This also does not seem to work when running at high time scales (I have been using the code where you perform multiple movements per frame depending on the time scale but this does not prevent agents falling through). I also tried a method where I sample the height of terrain during every movement and use that to set the nextPositions y component but again at faster time rates this just breaks the movement and causes the agent to move around wildly

Are you using RichAI?

Recast Graph doesn’t really care about being under/above terrain. RichAI is supposed to be used in pair with Recast Graph and it alignes itself with the ground using raycasts.

Yep I am using RichAI

Update:
I saw a post on here that said by using a CharacterController you can override the way RichAI determines uses raycasts to determine the ground (and presumably why it was leading to falling through the terrain)

It switched to using that and it is working really well, even at higher speeds

Update: After some further testing I am getting rare instances of my agents just getting stuck on the terrain when trying to use a character controller (i.e areas where there is a steep slope that richai thinks it can navigate)

Also having issues with the agent moving along a path and suddenly getting stuck moving back and forth in the same area instead of following the path

The last one is just RichAI being bad. Still hope that Aron is going to fix it, but I guess that it is better to write your own agent movement then wait indefinitely

@s.khan That is unfortunate. I have seen another post where Aron recommended using AIPath to get around this issue but not sure if this is a good idea

I encountered this. My solution was to make sure that all navigation targets fall on the actual nav mesh, not the visual mesh but to also split my AI into two pieces. The root of the AI has the AStarProject components and the visual part of the AI is a child that is snapped to the visual mesh. The actually AStarProject stuff is always snapped to the nav mesh and the visual stuff is always snapped to the visual mesh. I have a physics mesh for that which is more accurate than the nav mesh.

Hi

It’s true, the current movement scripts are not great at handling this.

However, I have been working on a new movement script (FollowerEntity), which is now available in the beta version. You could try it out, as that should handle the case when the navmesh is generated below the terrain a lot better.