Seek path over multiple gridgraph's

i have a huge terrain (400SqKm) generated at runtime in tiles with correspondent GridGraph, the pathfinding works great inside each tile however it cant crossover to other tiles, is there anyway to connect the graphs or merge them all ?

PS: The procedural example will not work because its an RTS game with multiple units.

Hi

Is only a part of the world loaded at any point in time? Are multiple disjoint regions in the world going to be loaded at the same time?

Hello, yes only certain tiles are being loaded (grids are generated at runtime), there could be some disjoint regions. for exemple if you exploring the map for a new base, eventualy the chunks behind you might get unloaded, but main base chunks are still visible, i dont need it to pathfind through the unloaded chunks, just walking betwen the ones that are loaded is enough.

Hi

Okay. This is possible, however linking adjacent grid graphs is not something that is supported out of the box.

If you keep your own internal list of grid graphs you should be able to link the proper nodes together using some code. Something like:

void AddGridGraph(int chunkX, int chunkZ) {
    ...
    // z = 0
    for (int x = 0; x < graph.width; x++) {
         var node = graph.GetNode(x, 0);
         var adjacentGraph = GetGraphAtChunk(chunkX, chunkZ-1);
         var adjacentNode = adjacentGraph.GetNode(x, adjacentGraph.depth - 1);
         var cost = (adjacentNode.position - node.position).CostMagnitude;
         node.AddConnection(adjacentNode, cost);
         adjacentNode.AddConnection(node, cost);
    }
    // Similar code for the 4 other edges of the graph
}

Another approach you could use which might be easier is to use overlapping grid graphs.
image
So you never actually connect different graphs, but you make sure that a given unit uses the graph which has its center closest to it. Since the graphs are overlapping this will ensure that the unit has at least 25% of the grid’s width of pathable space in any given direction (depending on how much larger than necessary you make the grids).
Also take a look at this tutorial for some info that might be useful: https://arongranberg.com/astar/docs/multipleagenttypes.html

For me, don’t work (i don’t know why) with two overlapping GridGraphs. Have you an example about that to connect two grid-graphs?

Same thing here. Overlapping grid Graphs is doing nothing. All ai are still stuck on the grid they start on. and can never leave that grid.

And, also, the code example for connecting grid graphs is missing too much key code for me to make sense of. For eg: Nowhere do i find or have the method GetGraphAtChunk();

This is disheartening honestly, as it seems it should be easy to do, and required by any game using more than a few yards of terrain space. Kind of shocked that i can’t ind a single youtube vid, or tutorial on this subject.

I cant make a grid larger than 1000 units, it seems to have issues beyond that… i cant get multi grids to combine… so im really unsure about buying this full version atm with my current experiences.

Maybe its just not built for us greenhorns. :frowning:

Hi

Grid graphs are artificially limited to 1000x1000 nodes. This is not due to an inherent limitation though, but only because large grid graphs use a lot of memory. 1000x1000 nodes is 1 million nodes, so every byte the graph has to store per node ends up as 1 megabyte memory usage. In pretty much all cases, you don’t want to use a graph larger than 1000x1000 due to prohibitive memory costs. In that case it might make more sense to use a recast graph which can cover much larger regions more efficiently. If you really want to, the 1000x1000 limit can be removed easily in the source code, though.

See also my answer to you in your other post.

Wow - thats a hell a lot of memory. useage. Thanks for the insight. It seems i am need to rethink my general setup and i need to understand more about A* first as well. Thanks for the info and insight.