Constrain path to graph?

So I’m using a grid graph for a 2D world. I want to make sure that my character doesn’t leave the graph while pathfinding to its location.

Here is an example of an unmodified path.
image

The character unfortunately will sometimes veer off when making intense turns. To prevent this I greatly increase it’s acceleration. I also added the Funnel and Simple Smooth modifiers to make the path more appealing. Unfortunately it now veers way off from the graph.

image

I selected “constrain inside graph” but, the “square” based nature of the graph makes the entity sort of “bump” and get caught against the corners as it’s trying to move to the location.

Any suggestions on how to fix this? Is there a way to make sure the path never leaves the graph? Or maybe curve the gaps?

Hi

The Simple Smooth Modifier will not take world geometry or the graph into account. It is generally used in low to moderate amounts so that it doesn’t risk entering obstacles.

In your case, I’d recommend turning off ‘cut corners’ in the grid graph settings, removing the funnel and simple smooth modifiers (or adjust it to a lower amount) and use the Pick Next Waypoint Distance setting on the agent as the primary path smoothing control.

You can also bias the agent’s path to make it try to stay further away from obstacles using the ‘erosion uses tags’ feature. See GridGraph - A* Pathfinding Project