How to check if object is touching astar grid bounds?

Hello,
does anyone know how to check when object with astar pathfinding is pressing on the grid bounds?


to explain better, I have a bee that is pathfinding towards the player inside the astar grid (the edges can be seen in the screenshot, white lines). When the player walks out of this area, the bee keeps pathfinding towards the player, but gets stuck on the edge and just waits there until the player returns into the area. Is there a way for me to detect when the bee is pressing on this edge, so that I could have it go elsewhere so it doesnt just camps near the edge waiting for the poor player to return?


Usually in a patrol situation like this you don’t ask so much if the bee is hitting its boundary, but rather “Is the player in a position that I can navigate to him in order to menace him?”

You can use the same bounds to check the player and see if the player is within the bee patrol area, and if not, just go buzz off randomly somewhere and hang out.

Or you could just check if the path was able to be created or not.

It can also be useful to have the bee hang out for a brief while before losing interest and going back to its honey collecting.