Support Forum

Best Solution for '2D Top Down'?

Hi. First of all, I am using AStar Project and it is so powerful, satisfying asset.

However, I got some problem these days.

My game’s maps are looks like above. I am managing maps by seperated scenes.
the problem is, how am I gonna create a pathfinding graph for each, efficiently?

Current Status
Right now I am doing like this, just add new graph for each map. This isn’t too bad, But things will get ugly if I want to enable pathfinding for whole map.

The Problems

  1. Managing graph like this is ineifficient. If I move my map, I also need to move my graph. I hope graph can be child of map but looks like it is impossible because we cannot have more than one AStar.
  2. I have more than 32+ maps. But Seeker component seems only support 32 maps.

In Conclusion
A. How do you think about the problems I asked above?
B. Do you have any other solution or example similar with mine? I think my game is similar with most top down RPGs. So there could be some way, I hope so. :stuck_out_tongue:

Hi

I’m assuming each map is separate so that you do not need connections between them.
In that case I think the more maintainable solution for you is to just re-scan the graph whenever the player moves to a different map.

See https://arongranberg.com/astar/docs/graphupdates.html#recalculate-whole-graph
and https://arongranberg.com/astar/docs/runtimegraphs.html (you wouldn’t need to actually create a new graph from scratch, but you could configure one in the inspector and then just move it to wherever your level is, and finally scan it).

Since your maps are tiny I don’t think performance will be a problem.

  • I have more than 32+ maps. But Seeker component seems only support 32 maps.

The package actually supports 255 graphs, but graph masks (which tells the agent which graphs it can use or cannot use) is limited to 32 graphs. The ones with a higher index will always be treated as walkable.