How to know if a path destination is inpossible to reach?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gruen

I use Pathfinding based on the tilemap.

the player can construct walls and thats the reason why a destination could be not reachable.

i need to detect that. is there a way to check if a path isnt possible?

Well i think maybe you can get the answer by checking the path.size()

:bust_in_silhouette: Reply From: jhigginbotham64

what needs to detect the player’s walls, and what are they supposed to do when their path is obstructed? Having the player place walls make it sounds like it’s an enemy. If that’s the case, then even if your pathfinding is based on the TileMap, you could probably just have the enemy raycast in front of them if all they need to do is check “is there a wall” and stop if there is.

But if you want them to path around the player’s wall, I would think that your best bet would be to incorporate the player’s walls into the TileMap and add them at runtime using set_cell or set_cellv.

If you weren’t using a TileMap for navigation then I would suggest AStar and are_points_connected. You may end up doing that anyway if it turns out that TileMap can indeed not do what you want it do.