Before we get started, it's a good idea to see how the object looks to us, so let's add in a temporary controller to give us an idea of what it looks like. Therefore, let's follow the these steps:
0
, 0
, 0
) from the Transform section. Then, you can double-click on the object in the Hierarchy tab to zoom to its position.You'll note that instead of the floor tile being in the center of the world when the position is reset, the pivot is off on the Z axis. This is because the art files that the artist provided to us placed the pivot there, which you will see if the Gizmo Display Toggles are set to Pivot (the button to the right of the Transform widgets in the toolbar). Now, since we're going to be placing these objects as tiles, we want them to snap together as easily as possible. In general, we want to place these pivots along one of the edges of the object. Some people prefer to place it on the center of the mesh, which you can easily do by changing the pivot toggle to Center by clicking on the button that currently says Pivot to change it to the Center move, but I don't like it, as it makes rotations and scaling more of a pain. For more information on the Gizmo Display Toggles, check out http://docs.unity3d.com/410/Documentation/Manual/PositioningGameObjects.html.
Floor_01_Modular_pieces_grp
object and select it. This is the actual mesh we want to work with. With it selected, go to the Mesh Renderer component and expand the Materials section. Then, change Element 0 to our house material either by dragging and dropping or clicking on the right-hand side circle button and then selecting it from the list shown. Finally, let's add in a box collider by going to Component | Physics | Box Collider.This collider is what the player will collide with in the world, so what you see will be what they will be walking into.
Floor
, and from the Project tab, create a new folder named Prefabs
. Drag and drop just the Floor
object as a prefab in the Prefabs
folder; optionally, you can place the object in a new folder named Modular Pieces
.As you can see if we move the camera, the two pieces together are already starting to look like a room. Not too hard, right?
Modular Pieces
folders, thereby deleting them as they go on, using Mesh Colliders on the Door Wall and Stairs objects.Hallway
and reset its position.The pivot of an object is extremely important when doing modular level design. We want to make it extremely easy for us to duplicate objects and snap them together, so picking a part of the object that will tile well can save you a lot of time in the future.
For those interested in learning more about creating good modular game art, check out http://www.gamasutra.com/view/feature/130885/creating_modular_game_art_for_fast_.php.
3.2
and Rotation of Y axis to 180
. Take a look at the following screenshot:This will act as our first building block, which we can use to create hallways by merely duplicating these Hallway objects.
Prefabs
folder named Tiles
. Make Hallway a prefab by dragging and dropping it in the Tiles
folder. Take a look at the following screenshot:Hall Door
. Then, add a Door object and a Door Wall object as children to the new Hall Door on the side that your wall object was previously at. Then, add Hall Door as a prefab in the Tiles
folder.You can make these doors functional later on, but for now, we are just building the environment.
To name the objects, I went with the following convention:
Left Stairs
. Go back to our Modular Pieces prefabs and then place two floors next to each other, one at Position (0
, 0
, 0
) and the other at (-3.2
, 0
, 0
). Next, add Stairs 1, Stairs Floor 1, and objects together, all at Position (0
, 0
, 0
). Add Stairs Floor 2 at Position (-3.2
, 0
, 0
). Finally, add two walls on the first floor (one with 0.0
on X and one with -3.2
) and two on the second floor (Y at 4
). Once completed, you should have a staircase built, as shown in the following screenshot:PrefabsTiles
folder. Be sure to reset the position of GameObject by right-clicking on its Transform component and by selecting Reset Position.