I’m trying to use IsPathPossible, but I want it to return true if we can walk next to the neighbours.
I have this code:
public bool CanReach(Vector2 position) {
GraphNode from = AstarPath.active.GetNearest(transform.position).node;
GraphNode to = AstarPath.active.GetNearest(position).node;
if (PathUtilities.IsPathPossible(from, to)) {
return true;
}
bool anyNeighbourWalkable = false;
// check if any of the neighbours of "to" can be reached from "from"
to.GetConnections((graphNode) => {
if (PathUtilities.IsPathPossible(from, graphNode)) {
anyNeighbourWalkable = true;
}
});
return anyNeighbourWalkable;
}
But for some reason, it always returns false in the picture below.