Help for huge 2D Top down map


#1

Hello,

We are making an online 2D game with a quite big map (~1200 * 1200).
We implemented some dumb AI and want to use pathfinding to make them follow different targets.

AIs would be able to search and follow targets 15 blocks around them.

What is the best way to do this? A small grid graph with ProceduralGridMover works well for one target, but I don’t know how to do it for multiple different targets :thinking:

We are using the latest pro version. Any suggestion would be greatly appreciated :grin:


#2

Hi

So you mean you don’t really have any use of pathfinding for paths longer than 15 blocks? Do you have to update the map at all?


#3

Hello,

The map has to be update regulary as players can add or remove some elements.
We currently do it by updating the graph for these elements.

We use a 60*60 grid graph with 0.5 node size and the ProceduralGridMover linked to a target (so it covers ~15 blocks around the target). We don’t need more for now as our AI will only follow close targets.

But we may have a lot of AI and possible targets around the map, and we don’t really know how to proceed :thinking:

Is grid graph the best option? (I didn’t tried recast graph)

(Thank you for the fast reply)


#4

Well. It all depends on how many targets you will need. You could make a 1200 x 1200 graph, that would use a lot of memory though and in the current version be very slow to update (I have some updates in the pipeline that will make that a lot faster).

If you measure things in tiles, you almost always want to use a grid graph. But it’s hard to say without knowing more about your game.


#5

Ok! I tried a 1000*1000 grid graph before the ProceduralGridMover approach and updates of elements were indeed slow. We can wait for this update if it will solve this problem :grin:.

Our game use a tilemap with a composite collider 2D for the terrain (this will never change) and the “elements” are player structures (such as fence, chest, buildings…) or ressources (trees, rocks…) that use specifics 2D colliders and can be added and removed at any time.

Edit: Just checked your new update, it works now smoothly thanks to the HierarchicalGraph. Thank you so much for your work! :grinning:


#6

Nice that it works with the new update! Let me know if you find any bugs or weird glitches in the pathfinding after the update.