BFS walkability constraint

Hello,

Currently, PathUtilities.BFS doesn’t search unwalkable nodes no matter the filter.
Is there a way I can get all nodes on a radius around a node no matter if they’re walkable or not ?

Thanks

Found my answer. GraphUpdateScene can modify tags instead of walkability allowing BFS to search them.

1 Like

Was about to answer your post, but it seems you already found the solution.
Yes, the BFS really cannot search unwalkable nodes because the grid graph will even remove connections to unwalkable nodes for performance. Tags on the other hand it can handle.

You might also be interested in https://arongranberg.com/astar/docs/gridgraph.html#GetNodesInRegion2 and https://arongranberg.com/astar/docs/gridgraph.html#GetNodesInRegion4 so an alternative way to get all nodes in a square around a node would be

GridNode centerNode = ...;
int width = 5;
List<GraphNode> nodes = AstarPath.active.gridGraph.GetNodesInRegion(new IntRect(centerNode.XCoordinateInGrid - width, centerNode.ZCoordinateInGrid - width, centerNode.XCoordinateInGrid + width, centerNode.ZCoordinateInGrid + width));

I am using an hexagonal grid so GetNodesInRegion couldn’t work properly but I will keep it in mind for future use.
Thanks for your answer.

1 Like