Sponsored By

Procedural Generation for Bunker Punks (Unity 3D)

Procedural Generation was something I was scared to tackle. With the help of a few great tutorials and a few mistakes, I got procedural rooms up and running.

Shane Neville, Blogger

March 31, 2014

3 Min Read
Game Developer logo in a gray background | Game Developer

This blog post originally appeared on the Bunker Punks Tumblr.

 

I’ve been wanting to tackle procedural generation for a long time.  

For me, it was a scary thing.  Lots of concepts I hadn’t tackled before and no tutorials for exactly what I wanted to do in Unity to be found.

When I started my research, I googled “Procedural Room Generation” and Noel Berry's tutorial was the first hit.  Noel is a friend of mine, so I knew if I got in over my head, I could always ask for help.  

Luckily, the tutorial and the code were well written and I had little problem porting it from XNA to Unity.

I was in a bit of a bind though. Noel’s tutorial is for 2D games, so all I had was a flat mesh with tiles on it and I wanted to build a 3D world.

At this point, I choked. 

I thought of building the world with prefab wall sections based on the data from ‘Noel’s World’.  This was pretty stupid and I knew it.  I abandoned fully procedural levels.

Instead, I built a system that would create a bunch of prebuilt rooms and connect them.  This was much easier for me to wrap my head around, but if I wanted any variety, I would have to build a ton of levels and update each level every time I added a new environmental option.

The room-to-room system also didn’t easily allow for the occasional long hallways, which is something I really wanted.

Back to the drawing board.

I really liked the patterns and randomness I got with Noel’s system, I just needed a way to get it to build 3D rooms without a ton of game objects for each individual wall piece.

I started looking into voxel systems and I found a great tutorial on building Minecraft style worlds in Unity.

Once I wrapped my head around the 3D chunk system, it was super easy to import the “Noel’s World” data to the voxel world.  Here’s a shot of the very first world generated with the new system (it’s missing floors, no big deal…)

I still have to add more variety to the room shapes and more variety in room styles (Pillars, walls, half-walls), but the hardest part is done.

Read more about:

Blogs
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like