Best practice for large worlds?

What is the best practice for large worlds that change during runtime?

I figured I would generate a graph at the launch of a new save and then save the graph along with the other save data. Then, I would update a small section around things changing in the world as they happened. The first part was no problem, but I’m struggling to get the runtime update to perform. I have tried using different graphs. The most promising one is Raycast, but the runtime update takes 10 seconds or more. I thought updating a small section of a tiled graph within a frame would be doable…

This is how I trigger the update. I figured I hardcode 4 units size for now as all the pieces that may change are smaller.

    float updateAreaSize = 4f;
    Bounds bounds = new Bounds(updateQueue.Dequeue(), Vector3.one * updateAreaSize);
    GraphUpdateObject guo = new GraphUpdateObject(bounds);
    AstarPath.active.UpdateGraphs(guo);

World size: 2048x2048
Cell size: 0.25
Tile size: 32
Min region Size: 3
Character radius 0.5
Rasterie terrain and trees
Terrain sample size 3

Am I approaching this wrong? Any suggestion how I can get the runtime update to complete in a reasonable time?

Hi

I’d recommend checking out the beta version. Recast graph updates are not only faster in the beta, but they are also better offloaded to separate threads.

Keep in mind that each tile has some overhead too. Usually I don’t recommend going below a tile size of 64.

Color me amazed at the upgrade.

I upgraded the A* Project but broke something else, so I couldn’t test it. Then I took my code with me on vacation, where I have a much less performant computer, and finally got to try it. I went from 18-22 seconds, where the game would freeze, to no noticeable delay within a frame. And that with a significant downgrade in hardware.

1 Like

I’m glad it improved so much for you :slight_smile:

By the way, if you want to support further development of the package, a rating and/or review in the asset store never hurts :slight_smile:

I’ll leave a rating and review once I have managed to do all the things that I want to do. Next up are stairs.

1 Like