Astar3D connect points and debug mode

Godot Version



I’m trying to create a game in which box meshes will be instantiated randomly when each level starts, and each box will have an astar point in it. But how do I go about connecting all the points dynamically, like when the boxes are close enough, they form a connection? And is there a way to view points and connected points in the editor or game view for debugging? Thanks.

The AStar classes (AStar2D/AStar3D/AStarGrid2D) have no visual debug, you need to run your own if you rely on those classes.

The AStar classes are very simplistic point navigation helpers that require to do nearly everything manually. The AStarGrid2D does a few things automatically because it is limited to a rigid grid layout that makes it possible to predict some stuff. In theory if you game plays on a flat plane you could use that and just convert your positions between 2D and 3D.

For AStar3D you need to do everything yourself in script. You could rasterize your boxes on a grid and do a cell neighbor search to build the connections to other boxes that are close enough. If your boxes are placed more “natural” so they do not align nicely with a grid use their e.g. mesh AABB and rasterize them in all cells that have some overlap with the AABB. What would work best depends a lot on the layout and what connection logic that you want to have.

1 Like