ClampToNavMesh for Grid Graphs

Hiya!

I’ve implemented pathfinding on my AI using a custom character controller. It’s all working great, but one feature of the controller is that it slides off collision in an attempt to feel smooth. (It does.)

This works great for the AI versus the environment, as if they try to slightly cut a corner, they will just slide around it. However if they attempt to walk past the player, they slide off the player and can be pushed off the graph. (Then they just freeze there, I assume because they’re not near any node.)

I noticed when I was creating my own version of AIPath that there is a ClampToNavMesh method, that I believe keeps AI on the NavMesh. I was wondering if anyone has developed a way to ensure agents don’t leave the grid mesh in a similar fashion? Freezing them at any boundaries (not just the outside edges) rather than letting them be thrust off.

Any help is greatly appreciated!