Building Levels in Unity – Part 2 of 3

Hi! It’s me again, Matthias of Paladin Studios. This is the second of three articles on how we built the level for the Kickstarter demo of The Fork Of Truth. You can find the other two post here:

Part 1 – A look at how the terrain in Unity works

Part 3 – Smaller and ancillary tricks that make the entire level come together.

In this segment I’ll go into the environmental objects, and how they are set up.

Basic Setup

When you work on levels, you have two approaches: Using a modular tile-based system (think “Lego”) or building everything manually.

Previous Paladin games, such as Momonga – Pinball Adventures and Nikko RC Racer use the build-it-manually approach. It gives you a great deal of freedom, but because the levels take more time it limits the scope of the game. The level construction also becomes an inflexible and time-intensive process, which hurts iteration and experimentation.

Tiles works differently. Instead of building every asset by hand, we create a set of building blocks, which can snap together. With a small set of blocks you can create some pretty wild variations.

Perhaps the biggest advantage of a tile-based system is that it allows for a quick build-test-refine cycle. Setting up (or changing) an entire scene is easy and fast, which allows you to quickly test different variations of the level.

Tiles

Everything in the game (buildings, crates, fences) is an “object”. Each is made to fit easily into the larger game, and it’s sized specifically to align to tiles. Because all objects are sized in this way, they also align to the other objects in the game.

An object is essentially a 3D model in Autodesk 3DS Max. Every object sits in its own file, and this file contains everything it needs. This is what an object could look like:

This proto-watchtower appears at several points in the level, and can be complemented with other objects like palisades, crates, barrels etc.

Note that the pivot point is at the bottom of the object. That way we can easily place all objects “on the ground”, as their zero-points are already there too.

We save this object in a folder titled “models” in Unity. From there, they are automatically imported into Unity, ready to be used within the game.

The proto-tower is not final, it is a simple blockout. The artists have made this for a general indication of size and shape, but we still need to make the final 3D model. We can already start populating the level with this mockup, by turning the 3D model into a prefab in Unity. These “Prefabricated Objects” will be the building blocks we utilize to assemble the level geometry. We automate prefab generation with Merlin’s Prefab Lab, a plugin that automatically creates a new prefab in Unity for every 3D model. When you then change the source 3D model, Prefab Lab will update the model inside the prefab while preserving the dependencies. When the prefab is up to date, all the objects in the scene will be updated as well.

Naming Conventions

Every team member can access, modify and create objects. As such it becomes necessary that each object is clearly named, so that there is no confusion in finding them in the huge library.

There are many ways to name objects, but we are looking for a structured way that allows us to find the objects in the project folders. Whatever convention you choose, be sure to follow it All The Time.

We use this convention:

“Tree Broad Leaved 01 3×3 Green”

The structure is “Identificator – Modifier – Variant – Footprint – Optical Distinction“, written with capital letters and spaces between the words.

It starts with the thing (“Tree”, “Rock”, “House”), followed by the main modifier (is it a large house? A small house?). This is followed by a running number, to allow for variants of the same thing (i.e. 2 different “Rock Large”). The footprint tells us how big an object is in tiles, so we immediately know how big it is without adding it to the scene. This naming scheme groups all related objects together naturally, so we can easily navigate the object library.

Placing Objects

To place an object in the scene, go to the prefab in your project-folder and drag & drop in into the scene:

That’s it! Repeat that with a several other items, and the level will fill up quickly. Then simply tweak the position and rotation of the objects until you are satisfied with the results.

Snapping Objects

Placing objects in a row is quite useful too. Since all objects have been built to fit the “grid”, they can be snapped together. This way we can create farm-fields (and other constellations) in no time at all:

Holding down Ctrl while moving an object will snap it to the grid. The snapping distance can be adjusted in the Snap Settings (Edit -> Snap Settings).

This is especially useful for fences. By just snapping them together we can create a longer fence in seconds:

Another way to align things is by holding down V while moving. This will snap the current object to any edge or point in the scene.

We can also add slight rotations to the objects while duplicating them. By slightly rotating each fence-piece before creating the next one we created this nice rounded enclosure:

Conclusion

Using a tile-based system allows you to create levels quickly and painlessly.

Think in terms of Lego, and determine the tile sizes you want the objects to fit into

Name the objects consistently for easy access

Use prefabs to let your object updates propagate throughout the levels

Use the Snap function to quickly create arrays of objects

For the final game we will create at least 12 levels, all much larger and stuffed with content. They too will be built on the tile system, which is essential for an efficient workflow.

Next time: In the 3rd (and last) part of this series I’ll go into all the little things that make a level come together, like lighting and sound.

Thanks,

-Matthias