Why does ABPath.Construct produce an indirect path within a navigable area?

Why does ABPath.Construct create an indirect path like this? I am using a Recast graph and accessing the values of ABPath.vectorPath.

Separately, is there a utility class that can convert vectorPath to bezier segments without the requirement of adding a MonoBehavior? I do not believe smoothing will address the correctness of this path ā€“ but it is definitely a next step after the path is optimized.

What you want is probably the funnel modifier. NavMesh graphs are plygon connections, so you get center-center polygon paths by default. The Funnel modifier uses the funnel algorithm (or string pulling, whatever you want to call it), to reduce the number of path corners. Note that the funnel algorithm will cause corner hugging when going around obstacles. But then there is the optional radius modifier as well, to semi fix that issue.

3 Likes

Thanks, CRGHans.

I have a FunnelModifier script added to the same GameObject which contains AstarPath. Should it be working? To clarify, I am accessing ABPath.vectorPath, and Iā€™m wanting to produce a usable path.

Hi

The modifiers are used together with a Seeker component.

If you want to use the AstarPath component directly, you can still apply all modifiers attached to a seeker as a post processing step by calling seeker.PostProcess(path) once the path has been calculated.

Thank you! It works very well!