Dungeon generated at runtime. Made up of similar rooms, recast vs grid / stitching?

Hello! Thanks for the plugin. I am at a point in my game where I am now using Dungeon Architect to generate prefabs in a grid. The prefabs are 1x1 or 1x2 2x2 4x4 all combinations of 1x1 and are stitched together in a large grid to make up a level.

I have a RVO Simulator / A Pathfinder Script with a Recast Graph (800 x 16 x 800)

Currently I am building the dungeon real time and then using a callback on dungeon complete. I am calling
pathfinder.scan();

pathfinder is just my Gameobject with the Pathfinder script on it and I have a recast graph with bounds pre-setup with something like… 800 x 16 x 800. The center point of my dungeon is 0,0,0 but it can go out in any direction 400 units… so I am stuck with a large bounds and only 1/4th of the bounds ever being used, depending on which direction the generator decides to spool out my level…

So a few questions…

  1. Should I attempt to get the dimensions of my generated level, and use that as the bounds… would that be better than just a static 800 x 16 x 800 or does it not matter if 3/4 of that bounds is totally empty, will that make the performance difference negligible? or would it be in my best interest to try to clamp the bounds down as best as possible rather than a really large safe area?

EDIT: - ok i found this already and Question 1 is answered! Sweet!

        if (AstarPath.active != null)
        {
            AstarPath.active.data.recastGraph.SnapForceBoundsToScene();
            AstarPath.active.data.recastGraph.forcedBoundsCenter.y = 0;
            AstarPath.active.Scan();
        }

So question 2 would be… should I use grid graphs over recast?
If i am using NavMeshCut on a pair of sliding doors would that mean i have to use recast? or would I be able to use grid as well and that doesn’t matter?

If i used grid graphs and I had 10 prefabs all 1x1 squares, should I be generating the dungeon. on callback of dungeon complete → finding the bounds, setting up a grid graph, then scanning during runtime? or should I be scanning individual grid graphs for each prefab before generation and somehow saving them? caching them? stitching them? any type of ‘advice’ or direction on what concepts I should be doing I will try to go that way…

Thanks!

just a pic to show the square pieces 1 unit each. and some are squares, some are T, some are L shaped (but all 64x64 units) 1U prefabs. I scanned the first one with a grid graph just to test.

It looks like your map is very grid-based. In that case a grid graph might be best. If you are going to use penalties/tags then I would also recommend a grid graph. But if you need more accuracy and possibly larger worlds, then a recast graph might be better.

A navmeshcut only works on recast/navmesh graphs. However there is also the DynamicGridObstacle which works on grid graphs (and recast graphs actually, I should change the name :p, it turned out to be more general than expected).

Since your prefabs seem to be quite small (I assume a prefab is a wall segment or similar, not a whole room) then I would recommend scanning the whole graph when the dungeon has been generated. For a grid graph in particular, this will be quite fast (even faster if you use the beta version).

Ok thanks for the info! I will check that out. My prefabs are entire rooms, but they are decently small, its like a Room based asteroid top down shooter, so every room has doors you go through and its a new square room, something like that… (but T / L and I shaped inside the same 64x64 prefab’d room) but I am also using the new beta and burst and so my recast graph scan is pretty fast as it is, and its 1 layer (ground) and no other tags or penalties

Is there a callback for when the scanning is complete, I am sure there is, I need to check that and I think I am good to go. thanks so much for the plugin, its great.