Beta - richai agents falling through terrain

This seems to happen occasionally and I can’t consistently reproduce it, but agents are falling through terrain from time to time.

They don’t use rigidbody or any type of character controller and have been relying on the RichAI gravity settings.

I don’t recall this happening pre-beta.

View from under the terrain, 4 agents fell through but the thing is they are just “lower” than the terrain. They aren’t sitting on anything else under the terrain as there isn’t anything there. They are just on a lower Y position for some reason.

View from above the terrain with 1 agent selected. These particular agents do have a fairly low collider.

Still happening. I tried some things to make sure there was a navmesh under the truck but that makes no difference.

On more testing, especially with low framerate sessions in the editor agents are falling through on terrain slopes as well as after having reached destination.

At this point I’ll have to stop using the gravity feature of RichAI because I can’t trust it.

A couple GIFS on my onedrive showing agents falling through/being underground:

Any other suggestions?


One thing that I notice is that you have some agents with a very small height.

The way ground raycasting works is that it will fire a ray from the center of the agent downwards.
However, if the agent moved enough in one frame so that the center of the character is below the terrain, then the raycast will not hit anything, and the agent will fall through the ground. This is likely what is happening here. It’s not really possible to distinguish between “I am below the ground” and “I fell through the ground” when this happens (at least not in a reasonably performant way). I would recommend that you raise the height of your agents a bit, and I think you’ll see that the problem disappears.

Any specific reason it raycasts down from center of the agent and not from the height of the agent?

Perhaps you can put a warning in when height is say < 2m and gravity is turned on to use a taller agent height?

Either way, yes that seems to be working now. I set all agent heights at 2m for now.
But I still don’t see why the agents were merely underground by a few meters, there is nothing else in the scene or my code that was trying to set their height and there was no other surface to walk on, so if the astar gravity check failed to find terrain does it fallback to doing something else?

Are there any scenarios you’re aware of where that might end up being a problem? Is it about getting through doors and other openings/caves like that when calculating the navmesh?

People sometimes have doorframes and other stuff that temporarily clip through character heads, so I figured the center of the character was the safest spot to start the raycast from.

Not quite sure what it ends up standing on below the ground…

After increasing agent heights (nothing lower than 2) the problem was gone, until now.
It showed up on 1 agent despite having a 2m height.

100’s of other agents no problem but this one fell through like before. I’ll have to go back to my own terrain height checking script because this type of problem completely breaks the level of my game since towers can’t hit it when underground.

I get that you need to do height checks from the agent height (or middle) for buildings and stuff if you have multiple levels/doorframes etc, but the agent should never fall through terrain no matter what.

I still have no idea what the underground agent is standing on.

This agent is also very slow moving so I don’t think agent speed had anything to do with it. They also don’t collider with anything (other than getting shot by turrets) and no rigidbody so I don’t see how they could have been pushed underground by anything.

Any other ideas?


That’s really strange. Especially for a slow moving agent, it really shouldn’t be ending up below the ground.
Is there a big FPS drop right when the agent drops below the ground? Or something similar?

It was running in the editor so who knows, but I didn’t notice anything severe, the FPS was fine (30-60).

My own version of the script raycasts down from 1000 above the agent so it’s working for now.

Was there anything else the RichAI gravity setting was doing (besides gravity fall speed), or what about FollowerEntity? I do want to switch over to using that so does it handle the ground/gravity check the same way as RichAI?

It will raycast down from max(lastY, currenY) + height/2. that really should work unless there are gaps in the ground, or the agent is, in one frame, moving into a step that is taller than half its height. I’m at a loss for what is going wrong in your case.

Do you have a video of it happening?