A* Pro for really large worlds?

Hello, how good A* Pro is suitable for a really large world?
We are talking about approximately 120km² consisting of 1kmx1km unity terrains, with fixed and variable buildings and about 300 wandering AIs.The pathfinding would only take place on the server here.

There’s some options. For units that are… y’know, 100km away from your players you can throw them onto a very sparse Recast Graph, but have them navigate a more dense and localized one when they’re nearby a player or have some defined goal.

Check out ProceduralGraphMover. There’s some creative options you can build around it.

1 Like

Thank you, that was very helpful and it looks very good. I let each AI create its own grid and then assign it to the ProceduralGraphMover. In the first small test with 150 AIs, it ran without any noticeable performance loss compared to a single grid, and dynamic obstacles are also recognized. If there are any objections or suggestions for improvement, please feel free to share.

void Start()
{
if (!isServer) return;

randomTimer = Random.Range(50, 150);
repathTimer = Random.Range(0f, repathInterval);

ai = GetComponent<IAstarAI>();

AstarData data = AstarPath.active.data;
GridGraph gg = data.AddGraph(typeof(GridGraph)) as GridGraph;

gg.center = new Vector3(0, -5, 0);
gg.SetDimensions(50, 50, 1f);
gg.name = gameObject.name;

AstarPath.active.Scan(gg);

int graphIndex = System.Array.IndexOf(AstarPath.active.data.graphs, gg);

var mover = GetComponent<ProceduralGraphMover>();
mover.graph = gg;
mover.graphIndex = graphIndex;
mover.target = transform;
mover.enabled = true;

Debug.Log($"Graph {gg.name} (Index {graphIndex}) wurde {gameObject.name} zugewiesen.");

}

1 Like

Hi

I’ve seen people use it with 10x10km recast graph worlds. Definitely doable.

I would not recommend having 150 graphs, with one for each AI. I’m not sure how you are not seeing a performance loss, but I would expect one…

I also cannot see any performance difference so far, possibly because the AI only uses small grids instead of a large one.

And yes, after further consideration, there will ultimately not be 150 or more grids in the world at once. I am building a hybrid system. Larger layered grids for e.g. cities, dungeons, or base raids, and procedural grids for individual roaming AIs that will only spawn when players are nearby.