How to make a dynamic AStar pathfining graph

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

I’m building a game with a regular square grid for A* pathfinding where the walls can be broken/placed like Minecraft. When a block is broken/placed, what should happen? Currently I delete/create the node (see image), but I was thinking, should I have a node for every square and create/destroy the appropriate edges connecting the nodes?

Astar pathfinding grid

:bust_in_silhouette: Reply From: Hasnep

I originally asked this question on the Godot Matrix a while ago, and the solution I found was to use the is_point_disabled() and set_point_disabled() methods of the AStar or AStar2D classes instead of using remove_point like I was.

You can see the documentation for these functions here.

void set_point_disabled ( int id, bool disabled=true )
Disables or enables the specified point for pathfinding. Useful for making a temporary obstacle.