Creating and placing props

Now, it's great that we have a layout, but just a floor plan would get really boring really quickly in a first-person game. Luckily, we have a number of props that we can use to spice up the level a bit and add additional detail to our world. Perform the following steps:

  1. First, let's move our Level 1 object out of the way for now by making it a prefab and then deleting it from the Hierarchy tab.
  2. Next, go to the Models/Props folder and select all of your models. Under the Model tab, check the Generate Colliders option, and click on Apply.

    This will create collisions for all the objects that we want to use. We didn't choose to generate colliders for the modular pieces because we will generate them from scratch for our rooms.

  3. Move the Bedframe object to your scene, and change the Position property of the object to (0, 0, 0) from the Transform section. To focus on the object, select it in Hierarchy and then press the F key (this only works if the scene is selected). Alternatively, you can also double-click on it. You'll note that in spite of being in the center of the world when the position is reset, the bed is off on the X axis, and that's again because of the art that we were provided with.
  4. The first thing that we want to do is assign the Props material to all of these objects. We could do the same as before, but instead, I'm going to place each of the objects at (0, 0, 0), then select the actual mesh for all of them by holding down the Ctrl key (Command on Mac), selecting them, and then setting the material.

    You'll note that the material fits really nicely with the models that were created. This is because the artist who created this used a UV map to tell the engine how to cut up the material and place it onto the faces that make up the object (the vertices). The texture that we have on the material is drawn in such a way that it has the appropriate part of the image at the right place. Setting up the UVs of an object is something that is done in a 3D modeling program, but when we load the model file, it contains this information.

    Take a look at the screenshot following the next information box.

    Note

    For more information on UV mapping, check out http://en.wikipedia.org/wiki/UV_mapping.

    Creating and placing props
  5. Just as we did with each of the modular pieces, make each of these a prefab inside a new Props folder, as shown in the following screenshot:
    Creating and placing props
  6. Now with this in mind, let's bring the Level 01 prefab back to the level. Let's start off by adding the simplest of props to add, the chair. Drag and drop a chair object in your level; you should note that it automatically gets placed on the floor at the right position, aside from the pivot looking quite out of place. Take a look at the following screenshot:
    Creating and placing props
  7. We could go back to our 3D modeling software to fix this problem, but perhaps you don't have access to the software, so let's fix the problem in Unity. Create a cube by going to GameObject | 3D Objects | Cube). Change the cube's Position property to (0, 0, 0) and Scale to (0, 0, 0). Then, we'll use Vertex Snapping to move the bottom of the chair's leg to be at (0, 0, 0), so it looks like it does in the following image. Feel free to hide other objects in the scene to make it easier to see by selecting them in Hierarchy and then toggling the check by their name in the Inspector:
    Creating and placing props
  8. Once this is done, delete the Cube object, create an Empty GameObject (GameObject | Create Empty) with the name of FixedChair, and have the previous Chairs be the child of our new one. After this, create a prefab named Fixed Chair in our PrefabsProps folder and then delete it from Hierarchy.
  9. After this, bring back our Level 01 prefab and now drop a chair in. As I'm sure that you can see, it's much easier to place them now. Take a look at the following screenshot:
    Creating and placing props
  10. With this in mind, we can also use the Rotation tool to rotate the Chairs a little bit and create some duplicates by pressing Ctrl + D, moving them and then rotating them to break up the symmetry:
    Creating and placing props
  11. Now, we can continue with this with the other props as well, placing them how you feel would make the environment look more realistic.
    Creating and placing props
  12. Next, make sure that all the newly added props are added to the Level 01 prefab, and click on the Apply button to save all the changes we made.

    We now have the first story all fixed; let's now show how simple it is to create a second level.

  13. Find a spot in your level that has an open space, and add in the LeftStairs object, adding in walls if needed to finish the space. After this, start placing tiles just as we did with Level 01.
  14. A nice thing to keep in mind if you want to only focus on one level at a time, you can select the Level 01 game object and click on the checkbox next to its name to disable everything about it, which will let you focus on just what you are doing with this level. In addition, we can use this in the future to also turn off and turn on levels to help with the frame rate if we have too many objects on the screen. Take a look at the following screenshot:
    Creating and placing props
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset