Hello, I’m new here so I apologize if I placed this in the wrong category or something. I am making a game and I want to make (possibly) an infinite procedurally generated maze that has predefined areas throughout it (like an area where you have to run through it, a completely dark area etc…) and custom rooms that I already made (just normal rooms that appear randomly throughout it where you can find loot and that kind of stuff). I looked everywhere on the internet and couldn’t find a single person who already did this kind of thing, I found loads of maze tutorials and it’s all so confusing because I have no idea how to do this, I think i know the logical way but I don’t know how to do this in practice. Also I would prefer blueprints because I chose that but if it’s easier in C++ then I guess I can use that as well.
not a guide, but a few random thoughts on the problem:
- In the first place - generate maze on the logical level. For example it may be a 2d matrix where each element denotes the content of each tile: {empty tile, wall, etc}. Likely, as is it won’t fit the concept of “premade rooms”(if they aren’t limited to a single tile), but it’s manageable to expand basic concept to be applicable to this feature.
Personally i wouldn’t attempt to do this part in blueprints, as i think it’s way easier to implement in c++ (complex math in bps is a pain to manage)
- When you finished generation of logical structure of the maze - visualize it in engine. As a few options(but likely not limited to):
- Each room\tile is separate level - then you may use level streaming to load this levels at proper places;
- Each room\tile is an actor - just spawn them at runtime at proper places.
Of course you will need to handle the seams between tiles. But the solution will depends on chosen visual style. In simple cases you may even plainly ignore this problem.
upd:
an infinite
all of aboves was written with static maze in mind. For infinite, instead of generating maze once at start, you will partly generate new parts when you near the edges and also removes the parts that’s you already leaved and will never return here. Ofcourse, assuming you talking about true infinite maze. If you want to be able to return to previous parts at anytime, you have to settle just on “large enough” maze and keep it’s structure in memory forever (visualization can still be streamed in and out when needed)
Well, I was planning like it was procedurally generated (with a seed) and then when the player moves I just load the maze near the player and unload the maze that is already far away from the player, but once again my main problem is adding static content to a non static maze.
What do you mean with static content?
Do you mean fixed rooms connecting randomly between other rooms? If thats the case just spawn a random room on the door to other rooms checking that there is enough space or following whatever rules you like. What shape does the rooms have? How many doors/connections each one have? Do you want to cover an area or spawn certain amount of rooms?
There is plenty of doc on the topic (Ex: Procedural Generation Of Mazes In Unreal Engine, Part II), but you will need to be more specific about what kind of maze/generation you want.
By static content I meant rooms that don’t change, they are pre-made. They aren’t connected to each other rather they are placed randomly throughout the maze, it’s a normal maze except every now and then there is a room with loot and that kind of stuff. So a normal maze, but sometimes there should be a room selected randomly from the preexisting rooms that are in a folder, and then it should be placed there and there should be an entrance and an exit to continue through the maze. I just don’t know how to allocate space in the maze generation for the rooms, and how to actually place them correctly, because the rooms (preferably) would not have the same entrance and exit, some could have 3, some only 2, whilst some rooms may only spawn at dead ends.
If you want a regular good old square maze you will have to do the maze and then spawn the rooms keeping the path viable (you can ensure the maze keeps only one solution by checking after the rooms are added and just closing other paths). For this to work you need the rooms at mazeCell*X size so all fits nicely.
If you dont need the maze to be square and dont mind having small gaps, you can just spawn the rooms as you create the maze like any maze cell but having more exits.
Or spawning the rooms and then connecting them like BSP(Dungeon Generation using Binary Space Trees | by Gonzalo Uribe | Medium), or