Gamasutra: The Art & Business of Making Gamesspacer
Building Levels in Unity – Part 2 of 3
Printer-Friendly VersionPrinter-Friendly Version
View All     RSS
April 18, 2014
arrowPress Releases
April 18, 2014
PR Newswire
View All
View All     Submit Event





If you enjoy reading this site, you might also want to check out these UBM TechWeb sites:


 
Building Levels in Unity – Part 2 of 3
by Matthias Zarzecki on 07/12/13 12:33:00 pm   Featured Blogs

The following blog post, unless otherwise noted, was written by a member of Gamasutra’s community.
The thoughts and opinions expressed are those of the writer and not Gamasutra or its parent company.

 
This article was originally posted on paladinstudios.com

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.

Part 1 deals with the basic environment setup in Unity, using Unity Terrain. If you haven't read it yet, you can find it here. In this segment I'll go into the environmental objects, and how they are set up.

Overview

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.

momonga_01
9

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:

lfg_model_watchtower

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 3x3 Green"

The structure is "IdentificatorModifierVariantFootprintOptical 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 drop in into the scene:

lfg_editor_01
lfg_editor_02

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.
lfg_editor_03

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:

lfg_field_01 
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:
 lfg_fence_01
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:
lfg_fence_02

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.

Curious about the The Fork of Truth? We are running a crowdfunding campaign on Kickstarter. Check it out, and if you like what you see, be sure to back the project and spread the word!

Thanks,
-Matthias

Related Jobs

Sucker Punch Productions
Sucker Punch Productions — Bellevue, Washington, United States
[04.17.14]

Director of Engineering
Gameloft
Gameloft — New York, New York, United States
[04.17.14]

Lead UI Designer
Gearbox Software
Gearbox Software — Plano, Texas, United States
[04.17.14]

Graphics Programmer
WildTangent
WildTangent — Seattle, Washington, United States
[04.17.14]

Game Producer






Comments


Josh Bycer
profile image
Great post, I'm in the process of building a basic game myself in Unity and it's great to get some tips. Could you explain a little more about the difference between holding down CTRL to snap objects together and holding down V to align them?


none
 
Comment: