How to Build a Procedural Level out of Instances, Lego-Style (C++)?

I am using Unreal 5, and have a handful of small level chunks, essentially pieces of a maze- a small room connected to a hallway, or a big room with a staircase in the middle, or a T-junction, etc etc. What I’d like to be able to do is mark the “Entry” and “Exit” points of each of those rooms, select a random assortment of them in a random order, and then build a procedural dungeon by loading them into an empty level so that the Exit point of one chunk lines up with the Entry point of another chunk.

I’ve seen a lot of mention of the Level Instancing, which feels like the system I ought to use, I’m just not totally sure how I should be using it for this. All the examples refer to the world partition and show people making large open-world maps, which is not really what I’m after. I need to place a specific collection of pieces in a specific order, and the location I need to spawn them in is dynamic, rather than following a grid. I also need this to work with replication, as the game is intended to be co-op. Any advice would be appreciated- I have a few years of unity experience but unreal is still rather new to me.

You sound almost the same as me! Level transitions with procedural level generation This will give you some keywords to search around.

I looked at the various suggestions and from what I could find, run-time created environments do not play well with the streaming options. I decided to go with making my own system (basically a chunk loader), but it’s way too early to tell if that was a good plan or not. Good luck!

I would suggest either having ready room instances chunks (blueprint) or creating rooms proceduraly with hierarchical instanced static meshes.

The rooms would need to be generated by a seed phrase. This would be the element that would be passed on for room generation to other clients.

Each room would need an entry, exit point (probably just a new derived from the scene component). Each room should have a list of adjacent rooms.

If you are not following a grid then you will still have to check for room overlaps. If this occurs during generation you will need to either change the room size or orientation or pick a new connection point (door, hallway etc)

Our intent currently is more like the blueprint solution you suggest, having pre-made level chunks we assemble at runtime. We already have a system in place which can take a seed and select a list of level pieces to spawn in order. I’m just unsure of how to actually physically spawn these pieces in and attach their entry/exit points.

(Levels colliding isn’t a concern, we intend to unload prior pieces as players leave)

Spawn them with spawn actor from class selecting the generated pieces class. If you need to manipulate level chunks (a group of spawned rooms) then have room manager that will contain the sets of rooms (probably a hashmap with an identifier and a list of rooms in a segment). Then you can selectively hide them / destroy then / recreate them if needed.

This suggested solution of yours would be using the blueprint level instancing? I forget the term for it, but it packs the uworld as a level instance and a blueprint