Placing tiles with grid snapping

Now that we have all of our tiles created, let's start building out our area:

  1. Put a tile prefab in the world of your choice. Hold down the Ctrl key, and pull it in an axis' direction. You may have noted a little snap that you wouldn't see when moving normally. This is due to unit snapping.
  2. Grid snapping is a really useful tool when it comes to building stuff inside Unity. Instead of punching in numbers all the time when trying to set the positions of all of these tiles, we can just set our Snap size to be the size of our tiles 3.2 x 3.2 x 3.2.

    Note

    In addition to movement, we can also snap rotations and scaling.

  3. Go to Edit | Snap Settings; we can change the value to snap easily by changing Move to 3.2 and Move Z to 3.561, taking into account the wall thickness.
    Placing tiles with grid snapping
  4. Now that we have the snap settings working correctly, we will place a hallway to start our level and reset its Position property to (0, 0, 0).
  5. Next, duplicate the mesh by hitting Ctrl + D, and then, holding Ctrl, drag the tile over to the right-hand side to continue the hallway.
  6. After this, I'm going to create a couple of other hallways and then place two Hall Door prefabs to fill out the area, as shown in the following screenshot:
    Placing tiles with grid snapping
  7. Now, we need to create a few rooms. Open your rooms prefab and from the top viewport, place your middle piece in front of each doorway by first dragging it out, resetting its position, then holding down Ctrl and snapping it there.

    Note

    Another way of placing assets in this way would be to place floors first wherever you want to create your layout and then spawning walls around the edges.

    Next, use the correct Room tiles to fill out your rooms as you want them to look. Start with using your Top Left, Top, and Right prefabs.

    Note

    Remember that once you place the object for the first time, all you need to do is duplicate, which should make it extremely quick to build (or prototype) levels.

    Once we get over the wall, you'll remember that normal tiles are still 3.2, so modify Move of Z as needed to 3.2 or 3.561 accordingly. You can also assemble tiles by making use of the vertex snapping tool. Basically, you can take any vertex of a mesh, and with your mouse, place that vertex in the same position as a vertex from any other mesh.

  8. Select the mesh you want to manipulate, and make sure that the Transform tool is active. Press and hold V to enter the vertex snapping mode. Move your cursor over the vertex on the mesh you want to use as the pivot point. Hold down the left button once your cursor is over the desired vertex and drag your mesh next to any other vertex on another mesh. You should see the object moving around via your input.
  9. Release your mouse button and the V key when you are happy with the results. This should make it really easy to build out the rest of the rooms, but make sure that you check at multiple angles to make sure the part is placed in the right area.
  10. For the sake of trying it out, go to the Hall Door prefab inside the Project tab, and you should see a little button to the right of the image of the prefab. Once there, click on it to have all the children objects show up so that we can modify them. From there, select the Door object and uncheck the Box Collider component. This way, you can walk through the doors to see the rooms. Take a look at the following screenshot:
    Placing tiles with grid snapping
  11. Using these same tools and a little trial and error, you can create a large amount of variety in your environments, such as the following:
    Placing tiles with grid snapping
  12. Finally, create an empty game object, name it Level 01, and assign all the rooms to it as children.

Save your level if you haven't already in the Scenes folder.

And there we go! We now know how to build out rooms using tiles and vertex snapping!

..................Content has been hidden....................

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