TwistedMind Ah... this concept is radically change my interpretation about the A* system...
Yes, you've been misusing A*, that's why you get this enormous slowdowns. I'd suggest to switch to Godot 4 if you can because AStarGrid2D will handle all of the described things for you. If you still want to use 3.5 then cram as much work as you can on AStar2D. However in that case you'll have to handle some things on your own.
The main thing you need is a function that returns a list of tile coordinates that represent a direct linear path between two tiles. Something like:
get_direct_tile_path(Vector2i(0, 0), Vector2i(5, 0))
This should return [(0,0), (1,0), (2,0), (3,0), (4,0), (5,0)]
Having this function is crucial for all of it to work.
So once you have the function, you should setup A* as follows. This runs only once after the map has been generated:
- Iterate through all tiles and determine which ones are corners. Those are your A* nodes.
- For each corner (A*node) find all other nodes that can be connected to it with a linear path without obstacles. Here you can use your get_direct_tile_path() function to get the tiles and then check if any of them is an obstacle.
- Now you have nodes and non-obstacled connections. This can be directly fed into AStar2D
Now for each individual pathfinding:
- Ask your AStar2D to get you the path between your start/end. It will return a list of A* waypoints, the start/end points may or may not be A* nodes. This list now represents a non-obstacled movement path from start to end via waypoints
- And finally use your get_direct_tile_path() function on each two consecutive waypoints to get the final tile-to-tile movement path.