5.4 Upgrade Question: Constraints and ABPaths

I have a question that is not answered in the upgrade guide, or I am just too clumsy to understand it (Upgrade Guide - A* Pathfinding Project)

I was previously using nnConstraint.Walkable with StartPath to plot a path and have the endpoint be the nearest point to a destination point:

/// 5.3.x
ABPath aiPath = ABPath.Construct(sourcePlayerPosition, targetPlayerPosition, OnPathComplete);
aiPath.nnConstraint = NNConstraint.Walkable; // find nearest walkable points
AstarPath.StartPath(aiPath);

The upgrade documentation does a great job describing how to use GetNearest with the new constraint API changes. But how would one instruct StartPath to use this constraint, so that it finds a walkable endpoint closest to the specified point?

I’m assuming it is more efficient to have StartPath() find a nearest end point and compute a walkable path instead of forwarding the result of GetNearest() to StartPath().

Hi

The behavior you describe has always been the default. So setting the nnconstraint in your case was not necessary. In 5.4 it’s still the default behavior.

1 Like

Thank you for explaining!