# Handling multiple agents in astar pathing

When working with grid based path finding in 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 map 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?

I am using the Godot Engine and would like to use the in built astar implementation but I can create my own if really needed.

This keeps it possible to add new actor types as well but is it waste of memory?

Each time you create a new AStar grid, you will be ocuppying more memory. If it is a waste or not depends on the size of the grid and the utilization frequency.

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?

You can

• remove_point ( int id ) : Remove the node where the another agent is
• set_point_weight_scale ( int id, float weight_scale ) : Set a very high weight for that node in particular
• set_point_disabled ( int id, bool disabled=true ) : Disable the node

Remember to undo the modification after the pathfinding

You can check for more on the Godot AStar documentation