Recast generated navmesh, path following

So I have got navmesh generated by recast.
This navmesh is a very rough approximation of a surface.
Because of this, paths generated are not exactly laying on a movable surface.

As I’m using multiple leveled navmeshes I cannot just remove Y component and check the distance to path segment only on XZ plane. (tried this and it was not working properly)

Is there a way to get the maximum possible value of the difference from this approximation to movable surface for the current graph.

If you got another idea of resolving path following I will be happy to know it.


I would recommend using physics to position the character on the ground. That’s what the included movement scripts do (e.g AIPath/RichAI).
Check out

I’m using physics to move my characters and they are positioned on the ground correctly, but the problem still exists.

Because the main problem is how far from path the character is if the path was on a surface. XZ are not a problem, now how can I compute the real Y component. I probably could do with this maximum error of “navmesh to real surface Y distance” recast allows when generating navmesh.


Ok. You can reduce the tile size of the recast graph. That will limit how much it can deviate.
Also in version 4.x it will be a bit stricter about not allowing the borders of recast graph tiles to deviate along the Y axis from the real ground. In 3.x it will simplify those borders a lot more.

If this doesn’t help. Do you think you could post a screenshot of your game with the graph you are using?

Yes but the question is still present, how much it will limit.

I could play with parameters, but it still gives me this impression of hacking around and waiting for disaster.

Here is the picture:


Currently there is unfortunately no such limit. Though for this case it is something I could add I think.
There would still be no hard limit because the navmesh algorithm does not generate inner vertices so if you had a small hill, the top of the hill could potentially be very far from the actual navmesh.
However in this case it is the edges of the triangles that are far from the original voxelized edges.

Usually this is not an issue because any obstacle will split the navmesh and thus lower the height differences, but it can happen in cases such as yours where you have a large sloping surface with very simple borders.

Well if it is only for the edges than don’t bother.

For now I kind of got a solution, I will test it for a while.
I take position on navmesh at position the unit is in and use the difference as an additional error margin.