November 3, 2015 by jonmillymiles
Aim – to create a blueprint that procedurally generates a dungeon as a level for a game.
Procedurally generated content is created within the game engine at run time through the use of an algorithm rather than being designed by a level designer. In order to effect good game play from the level it is essential that the algorithm is tweaked to generate best effect for the game style that is intended.
Some modern games such as Sir, you are being hunted! (Big Robot, 2013) feature randomly generated landscapes for the player to explore and escape. Others, for example Pixel Dungeon (Retronic Games, 2015) place the player in a dungeon that they must then explore. Such roguelike games demand a different style of gameplay tactics which are independent of the level design, based around unit strengths and weaknesses and player choices.
To begin with I need to look at the generation of simple content within the game engine (Unreal Engine 4.9.2, Epic Games) and to use the Blueprint system to generate code that will create a floor plan.
To begin with I worked on individual components and attempt to join them together. As an initial test I have taken a simple tile and used the construction script to generate a room based on two loops, one to generate a line of tiles and a second to generate more lines until a defines width and length is created. This was relatively straight forward:
This creates a rectangle of tiles that the user can control. To automate this, we simply set the width and length variables to be randomized within the construction script and the rooms will be procedurally generated each time they are created.
Now when we place these in our world the room size will vary with each change. If we want this to change each time the game is run we need to add them into the level blueprint activated by a Begin Play event. Like this:
This gives the following result:
There are some flaws with this methodology. The main one at present is that none of the rooms are connected up, nor is there a suitably controlled manner of their generation. As such, while this proves that rooms can be generated at random within the control of defined parameters, it shows that the algorithm is neither as refined as it needs to be nor as complex.