Support Forum

Recast Graph not following terrain

Hi Aron,

The recast graph when generated over undulating terrain does not follow the terrain. It can be metres below the surface. I tried adjusting most of the settings to improve the graph to make it more closely follow the terrain, but without success.

In the video I generate some cubes on the surface of the graph, this demonstrates how far below the terrain the graph is generated in places.

Is this because the recast graph just flattens the world to generate the graph? resulting in the large triangles that just ignore the undulations of the terrain?

The only solution I can think of, is to increase the number of tiles which would force smaller triangles.

Excuse my terminoligy… Could the recast graph have an option for setting max height variation for a triangle? i.e. Check all terrain vertices within the triangle for max/min, if max-min exceeds a threshold, split the area until hieght variation is within limits?

How can I get the graph to follow the terrain better?


Yes, this is by design for what the navmesh is optimized for. It does have weird side effects for large undulating terrains though, as you have seen. Usually pathfinding doesn’t care much about the y coordinate, so as long as the navmesh is not really far off, this isn’t a problem. However if you have very large open areas like that it can lead to issues. There are some ways to solve this:

  1. Add more obstacles to the terrain. A few trees or rocks (which you’ll usually have in the game anyway) will break up the navmesh nicely.
  2. Reduce the Tile Size.
  3. Use another graph type altogether, such as the grid graph.

Thanks Aron. I appreciate the tips. Yes, the pathfinding was working fine and the scene when populated, it is much better.

I was using the graph to find spawn locations and items were spawning below or in the ground. I now iterate up 1 meter at a time and do a raycast until I find the ground. I need the 1 meter increments because the graph could have a multistore building.

1 Like

I think the problem with saying that adding objects to the terrain helps with the issue is that we shouldn’t be exposing the mechanics of the game to the user. If we’d like someone to walk in these areas then we can’t say to the user “oh please place some rocks near by” because that breaks the immersion.