Checking if a position is in the graph bounds

Is there a quick way to check if a position is a valid one and not out of bounds for the graph types? The bounds variable on the Grid Graph return zeros (checked the code and it was commented out).

I’ve been forecasting a path and then checking if the last node on the path is close to the targeted endpoint in the OnPathDelegate call back. Not sure if there if this is the best way to handle this but its pretty quick and simple: if If(Vector3.Distance(WayPoint.transform.position, path.vectorPath[path.vectorPath.Count-1]) > 3) <–this tells me the target is nowhere near the path end point.

I’m trying to pick a flanking position on either side of a target to path find to. If the point picked is blocked by a unworkable, I simple increment it by the node size(using grid graphs). Currently i just graph the graph directory, get it’s centre then use the width and depth multiplied by the node size to calculate a bounds. Probably not the right way to do it but it works.

Hi

You can try getting the closest node to that position and checking if it is close enough, as a bonus you can then also check if that node is walkable.

GraphNode node = AstarPath.active.GetNearest ( somePosition, NNConstraint.Default ); if ( ((Vector3)node.position - somePosition).sqrMagnitude < limitDistance*limitDistance && node.Walkable ) { // Works! }