[WIP] Escape The Maze Survival - Procedural Generated

Over the past few weeks I’ve been working on a concept based off the maze runner film. I liked the idea of starting in a maze and having to try find your way out without dying. The first goal of mine was to create the actual maze that the player would try and escape from. The one thing I want for the whole project is to have everything procedural generated so each player can get a slightly different experience.

I set out looking at different maze generating algorithms that I could use. For this I settled on the backtrack algorithm and was able to get a good start. Below is what the maze initially looked like.

After completing the initial maze generated I did make a tutorial for it which can be found here. Since the completion of the tutorial I’ve been think of the aspects I want in my prototype and decided I need some way to spice up the mazes themselves. I began modifying my initial maze generator to allow the adding of even more static mesh instances that currently adds bridges, wooden barriers and (totally the best) foliage along the path of the maze.

Below you can currently see the progress I’ve made. At the moment I’m currently trying to think of static assets that might looks good in the maze and help break up the repetitive feel.

My current plan is to try flesh out the maze more before moving on to the mechanics side of the prototype. If you have any questions and any feedback feel free to post. Also if you have any idea’s what other types of assets my work to flesh out the mesh let me know. :slight_smile:

Hey everyone. Today I decided to sink some more hours into this project. My main goal for today was to spruce up the walls. I went into blender and created 6 meshes I wanted to use for the possible wall types they would. This was the easy bit. The hardest bit I found, (initially that is) was knowing which mesh to spawn where and whether or not it needed rotating. This was achieved easily using a binary approach with bools. I ran a check to see if there was wall tiles next to the current one and depending how many wall tiles where next to the initial tile would spawn in a corresponding mesh and rotate it accordingly.

Thus far I’m happy with the way it’s turned out thus far and the resulting change has given in some places an addition 4m of space to work with. :slight_smile: My next goal I think will be to add some form of height change to help break up the flat maze. Not completely sure how I plan to do this but I’m thinking about possibly adding almost like structures on top of the maze. This could also for some areas where the player can get higher up to get a vantage point of the maze.

Let me know what you think. Any C&C’s are appreciated.


This is really cool and promising stuff :slight_smile: I love all the projects popping up showing how UE4 is surprisingly good for procedural generation. Instanced static meshes really are a godsend.

How do you plan the gameplay to be? Will you be chased by a minotaur? Will it be filled with deadly traps and riddles like in The Cube?

The maze looks really cool from above, so you should consider dropping the player in from above so they get a quick look before they start.

Looking forward to seeing this evolve!

Well my idea is to have a safe(ish) spot in the very center of the maze. As the player you would venture into the maze to collect resources to keep yourself alive long enough to escape.

I’m wanting a day/night cycle where at night the maze will close off which could leave you trapped inside at night. At night I would have 2 or 3 different types of enemy’s that would emerge and want to kill the player.

I was thinking about adding traps as well in odd places that could catch the player of guard or even to use as a means of killing the enemy’s. At the moment I’m still working on the general structure of the maze and today I’ve worked on the second tier. To get onto this tier you would need to find a ladder that would allow you to get onto the wall. My end goal it to have area’s on top of the archways as a tier 3. I feel this helps a lot with feel of the maze with the elevation change. I do however need to do a bit more planning on this part as allowing the player complete freedom on top of the walls would ruin the feeling of the maze.

Hi pattym, I’m currently reviewing your tutorial. Awesome work! I wrote a few Depth-First Maze Generators back in UDK. I’m writing an new Labyrinth Generator with Blueprints to powered my FPSRPG. There are many Maze Creation Algorithms to choose from. The Algorithm I choose to generate the Labyrinth is based on how difficult it is to solve. The Recursive BackTracking looks promising.

I’ve always been fascinated with Mazes/Labyrinths from Mythologyv (Minotaur/Medusa), and the Maze Runner Film proved that Mazes are relevant in modern storytelling and inspirational to others. For me, unlike most level designs, the Maze itself is the challenge without any additional moving parts. Its an opponent to be conquered in the game world, not just architecture. Even with this being the case, I think the Maze by itself would get boring fast, so adding Monsters, Traps & Loot simply adds more FUN Factor.

I’m also pursing Procedural Generation for everything from Weapons to Monsters, coupled to lots of User-Mediation, so Players can create and customize practically all game content. My primary driving factors for this approach is Lack of Content Creation Skill & Artists/Budget. Lol. Static Mesh Instancing is awesome and makes many things visually possible that weren’t feasible a decade ago. Imagine expanding your Maze to 10k Cells.

I like the Survival aspect you’re going in with your game. The maze is taking on an interesting design. The second tier presents a another maze layer atop of the first, as if its two mazes in one. Its going to complicate you’re AI, unless monsters only roam on the bottom tier? There is a little controversy over the Griever Design in the Maze Runner Film as they don’t match up to the book. I wonder what interesting twist you will give them, unless they’re humanoid ie: Minotuars. There’s a couple of Day/Night Cycles: 1, 2 on the forum.

I’ll have to keep my eye on this to make sure I’m doing things different. Lol. Keep up the good work.

Hi pattym, just following up on your progress with this project. Any new developments?

I hope pattym is still working on this, looks awesome

Hey, this is something I’m still working on however I’m taking a little break from the whole maze gen stuff. (there’s only so long you can start at the same blueprint) Since the last update I was looking at refining the second tier when I ran into a problem.

Performance wise it’s better to have smaller mazes connected together as opposed to one larger maze but this has a few issues. With the way the maze is generated it uses numbered tiles this causes a problem in regards to combining smaller grids to make larger ones. This is needed to make sure there’s no seam between the different maze blueprints. Converting the tile indexes of a small grid to that of a larger one is some what confusing. I think I’ve just about figured it out but not got round to testing it. Below is a picture to explain what I mean. Top number is the small grid index and the bottom number is the large grid index. I think the equation is right lol.

Gaps appear near the edges where the mazes join which isn’t avoidable with the current system I use. The overall plan is to have one master blueprint that contains (thanks to 4.7) the maze gene blueprint (with tweaks) that generates the small parts of the maze and then passes it onto the master blueprint. I can then use the master blueprint to spawn in the instances which would then allow walls at the seams to display the correct meshes and form correctly. This will also help reduce (if not eliminate) any overlapping meshes. One step at a time though lol.

This process is a must to allow for a better second tier as I wont have to deal with boarders which kinda mess things up a little. :confused:

Recently however I’ve been working on an inventory system which I guess any survival games needs so I may as well show you a screenshot. :stuck_out_tongue: Not sure if the look will remain the same for this project but I guess it would fit the style.

The inventory system is a simple press E to pick up type of system. Thus far I have the display working as well as item stacking (which can be disabled). My next step is to set it up to allow the player to rearrange the inventory as they like as well as adding a method of using the items. I’m currently trying to make it flexible so the same system could be used for things like chests and barrels.

I’m going for a single floor mega maze structure up to 200 x 200 cells. I attribute performance issues to spawning mesh components, otherwise the speed to generate a 200 x 200 maze structure stored in a array is equivalent to this. I’m using Meshes (not instanced meshes) for greater control. My solution is to reduce rendering processing using mesh caching and level-of-detail.

Nice Inventory System. Every good addictive game needs a one… Lol. I just recently completed the UMG Inventory Tutorial. Although our approach differs slightly, I feel we’re practically making the same game: Maze, Monsters, FPS, Survival, RPG elements, Crystal Shards etc. Are you going to add RTS elements?

You would think it would be down to the meshes spawning in that cause the time to gen but nope. Here’s an example I did using a new system I’m working on.

This is roughly the size of maze your going for. I generate this in approximately 20 seconds at run time by spawning in a new maze chuck every delta second (pretty sure the delay as a min limit though). If I was to get a single maze to generate this continuously I’d be waiting ages for it to generate. I’m probably going to get fed up and end UE4 lol.

Just to show the flexibility of chopping your maze gen up here’s a 420x420 maze that only took about 1:30 minutes.

Doing it this way also (hopefully) will allow for the master blueprint to control what spawns in. With a maze where the tiles are about 4m4m in size (makes a chunk of 21 tiles 84m84m) there’s no really need to show more than 1-2 chunk radius around the player. This makes it better for when your throw foliage and other fluff around your level to spice it up. Trying to load and run an entire level the size of 840m*840m with fluff is going to impact of frame rate a lot.

Nice. I speculate you could actually create an Infinite Maze by interconnecting entry/exits of one sub-maze to another. Is that seam between the mazes desire?

Yes with the new setup I could generate infinite mazes, once I get the loading/unloading stuff sorted. Each chunk gets it’s own seed based on it’s location and the overall master seed.

Things I’ve still got to do is readd a loop paths option to help add a few extra possible turns as well as something to fill in the boarder so you can’t see the seems. For now though i’m trying to sort the loading/unloading of the chunks but I just keep causing the editor to lock up. :frowning: Maybe some sleep and a rested brain will give me better ideas lol.

I think I could probably rig the generator to do a full 3d maze which I may also do for the fun of it.

Infinite Random Maze Generator

Hey everyone, here’s an update on what I’ve been doing this week.

So I finally got the chunk loading/unloading of the maze to work.

Infinite Random Maze Generator

Current features:

  • Definable chunk size, smaller chunks are faster but generate less random mazes.
  • Changeable load distance.
  • Automatic loading and unload of chunk pieces.
  • Smart seam filler to connect chunks together.
  • Changeable seam path limit.
  • Changeable loop path limit for chunks.

Still to add:

  • Dynamic mesh placement based on neighboring tiles.
  • Definable maze size limit, 0 being infinite.
  • Server replication across all player.

Things to do:

  • Clean up the seam generation system and streamline it.
  • Look for ways to optimize the blueprints further to improve loading/unloading performance.

Without further a do here’s a video with it in action.

Any questions feel free to ask.

[video]UE4 Prototype - Infinite Random Maze Generator - V1.0 - YouTube

Whoa. Nice! Replicated too? Could Object Pooling/Caching be of use to improve loading/loading performance?