Multiple agent types for AStar paths

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

When working with grid based path finding in Godot how do you normally handle different agent types? In the game I am working on I have a regular agent, and one that occupies 2 cells on the grid, and one that can fly. The idea I have now is to use a separate AStar object to store the grid for each type. The height is max 4 units so I can use AStar for flying as well.

This keeps it possible to add new actor types as well but is it waste of memory? Also how to deal with avoiding nodes occupied by other agents? The game is turn based so I don’t want to do any object avoiding type thing. Is there a simple way to mark a node in the AStar as temporarily unwalkable?

:bust_in_silhouette: Reply From: Sween123

Create a dictionary to record infos for each tile. When tile is occpied, update this in the dictionary.
When using AStar, add tiles that has occupied == false.
Or if you want to keep the original added tiles in AStar, disconnect the tiles and their neighboring tiles when their methods OCCUPY() is called and reconnect them when “occupied” is turnd to false.

:bust_in_silhouette: Reply From: ariorick

As to avoiding nodes occupied by other agents or making all the air points inaccessible with AStar there’s a method for it.

void set_point_disabled(id: int, disabled: bool = true)

Disables or enables the specified point for pathfinding. Useful for making a temporary obstacle.

It seems to me that it might be OK to have different instances of AStar for types of movement like flying or walking, so you won’t have to disable and reenable too many points