The node to search from. Only borders connected (directly or indirectly) to this node will be considered. This could for example be the node that an agent is currently standing on.
Information about the closest border, if any was found.
)
Finds the closest navmesh border to the given position.
var origin = target.position; using (Draw.WithLineWidth(2)) { if (AstarPath.active.GetNearestBorder(origin, NearestNodeConstraint.Walkable, out var hit)) { Draw.Arrow(origin, hit.point, Palette.Yellow); Draw.SphereOutline(origin, 0.1f, Palette.Yellow); Draw.SphereOutline(hit.point, 0.1f, Palette.Yellow); Draw.Ray(hit.tangentOrigin, hit.tangent, Palette.Purple); } }
Return
True if a border was found, false otherwise.
Note
hit.node will always be null, as it is currently not possible for the code to figure out which border belongs to what node. You can call AstarPath.GetNearest with hit.point if you need this information.
Information about the closest border, if any was found.
)
Finds the closest navmesh border to the given position.
Return
True if a border was found, false otherwise.
var origin = target.position; using (Draw.WithLineWidth(2)) { if (AstarPath.active.GetNearestBorder(origin, NearestNodeConstraint.Walkable, out var hit)) { Draw.Arrow(origin, hit.point, Palette.Yellow); Draw.SphereOutline(origin, 0.1f, Palette.Yellow); Draw.SphereOutline(hit.point, 0.1f, Palette.Yellow); Draw.Ray(hit.tangentOrigin, hit.tangent, Palette.Purple); } } This method will first find the nearest node to the specified position using the specified constraint. You can think of this as the node the agent is currently standing on. Then, it will search for the closest border to that node, which is connected to it.
The constraint is only used to find the nearest node, it does not inform what borders are found afterwards. Notably, if an agent cannot traverse a given tag, it will still not consider a border between that tag and a node with a walkable tag as a valid border.
On a point graph, this method will always return false, since point nodes do not have any borders as such.
Note
hit.node will always be null, as it is currently not possible for the code to figure out which border belongs to what node. You can call AstarPath.GetNearest with hit.point if you need this information.