Last time we discussed how our Prop generation system has 3 basic elements / behaviours:
- Spawn a set of children
- Spawn a Random entry from a list of children
- Automatic discovery & configuration at Edit time
Let’s take a look at what this looks like.
It’s nothing particularly fancy, but let’s dissect what is going on. We have multiple layers of Props (remember, Props are hierarchical in nature), each combining together to create the bookshelf that we see.
The Prop component has 2 lists and a few helper methods:
There is the ‘Prop List’ – which is #1 from our list above – the Prop will spawn ALL of the entries in this list.
So we have the bookshelf itself, and then the 3 shelves.
Simple enough so far, right?
From the image above, you can see the first entry is simply the bookshelf itself – the base mesh – in this case it is simply pointing to a mesh in the project folder. Nothing special there.
The second entry is pointing to a child Prop called ‘Shelf Randomizer’. Let’s take a look at the ‘Shelf Randomizer’ prop:
Here we can see that the shelf randomizer has 6 entries in the ‘Random Selection List’. This means that when the Shelf Randomizer is initialized, it will pick from one of these 6 shelves to create our shelf.
Each of the shelf entries are in turn a child Prop as well!
The Shelf is where the actual layout of the shelf details happens – in this case, placement of a bunch of different books in random configuration.
The important part about the shelf layout is that it is entirely ‘Artist-directed’ – meaning that each and every one of the layouts was created and directed by an artist, and then fed into the randomization system. I’m not procedurally placing every single book at runtime – in fact I don’t WANT to have that level of procedural-ness to the environments. Artists and level designers are completely in control of the layouts, while adding this extra layer of dynamics to the layout. This provides greater reuse of assets and prefabs and in general provides ‘more bang for the buck’ when it comes to level design.
The artists & designers can use whatever tools they feel accomplish the task (procedural scattering / hand placement, etc) and the Prop system allows them to capture the results and create new variations very quickly and easily.
Here’s a gif of me hitting ‘initialize’ a bunch of times on the Shelf Randomizer’ Prop – we can see the various configurations that are spawned:
To summarize, our procedural bookshelf is comprised of 3 levels of ‘Props’:
- Bookshelf Mesh
- Shelf Randomizer (top shelf)
- Shelf Randomizer (mid shelf)
- ShelfRandomizer (bottom shelf)
- Shelves (6 variations of shelf layout)
The system is very simple (on purpose) and is simply a tool in the level design toolbox. Because these Props are individual elements that I can place in a scene, they can be used to supplement an existing scene or room layout very easily, adding a flavour of randomization to any environment!
Next time, I’ll show what this looks like extrapolated to larger environments, street layouts and entire buildings!