BFS walkability constraint


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 ?


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 and so an alternative way to get all nodes in a square around a node would be

GridNode centerNode = ...;
int width = 5;
List<GraphNode> nodes = 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