Roguelike Generator

As an assignment at university, we were tasked to improve Unity's Roguelike sample project. An improvement deemed acceptable was mirroring the character's sprite when it would move in a different direction. I decided that this project wasn't worth my effort, so I made the decision to improve every single aspect in a new project.

I proposed to change the level generation, enemy behaviour and the health system. I would add weapons, inventory, a boss, chests, controller support, armor and more. This would not be feasible within 8 weeks, so I started on the first feature and worked my way down the list. In Unity's project, the scene was generated on a grid of 8x8 tiles. During generation, the walls, enemies and food (increase score) were scattered randomly. Most students made the grid bigger and added weights to the amount of enemies and food spawned.

I on the other hand changed the entire generation and art style. The first step was making a main path. This ensures the level always has a start and an end. The second step was adding additional rooms for the player to discover.

Step 1 Step 2

In order to make the levels feel less like a grid, room corners are offset by a random amount to make the room shape more unique. This is also the step where every node gets a room type assigned. It can be a room (square) or a hallway (circle).

Step 3 Step 4

All of the room data is now generated, so it is time to generate meshes. The room-mesh generator takes in 4 corners and generates a grid within those points. This ensures a tilable floor texture can be used on each quad. A wall height variable dictates the height of the walls.

Step 5 Step 6

To prepare for some AI, a navmesh can be generated for this procedural dungeon with the NavMeshSurface. The normal navmesh can not be baked in realtime.

Step 7

I changed some of the textures and added both gameplay and decoration objects. Gameplay objects are things you can walk into or can be used to block bullets. Decorative objects are simply there for decoration, a character can just walk through them.

Step 8

Now it is time for the character. This character can be customized with multiple different styles of hair, skintones, faces, clothes and different hands. The same system is then also used to generate enemies, they just use a different set of sprites.

Step 9

I opted for this roguelike to have guns, since the old project did not have any attacks. A custom inspector was created to make it easier to position the hands. At the bottom, the different colored squares indicate where the left hand, right hand and the barrel is located on a gun. This was created this way since the game featured a few different guns.

Step 10

Since the world is 3D and the characters are 2D, the gun needs a special curve when aiming. This ensures the gun is always visible and is not clipping through the ground. (Setting up a second camera or change the shader was not on my mind at that time.)

Step 11

Roguelike game

Improvements

If I were to recreate this project, I would simplify the generated meshes and use a shader to aid with the random tiling. Rooms are also still on a grid, the corners just have an offset. To improve the rooms, I would let every room generate its own shape and place itself next to a previous room. I have applied this technique in another project, which you can find here.