From the course: Unity 5: 2D Level Design

Build a level - Unity Tutorial

From the course: Unity 5: 2D Level Design

Start my 1-month free trial

Build a level

- [Instructor] Now that our project is set up correctly, and we can test out our game, it's time for us to create a new scene for us to work in. Let's go into the jetroidLevelDesign folder, create a new folder, and we're going to call this Scenes. Then from File, select New Scene, and then let's go ahead and save this into our scenes folder. Let's call this scene LevelDesignStaging, open up the JetroidLevelDesign folder, open up the Scenes, and save it in here. Next, we're going to need to set up our main camera. Let's select the camera. We're going to change the Clear Flags to Solid Color, we'll change the Background to black, and we'll set the scale to 8. The next thing we want to do is add a script that will allow our camera to follow the player, and to also resize itself at different resolutions. Let's go to Add Component, and let's type in follow in order to find the Camera Follow script. Once you've added this script to the camera, it should now be set up the way that we need for our game. Next, we're going to go ahead and create a tile map. We're going to use the custom tile map editor that we imported earlier. Let's go to the GameObject window, and at the very bottom, you'll now see a new option to create a tile map. Select that, and a new tile map game object will be added to the scene. In order to use this, we're going to need to set a texture. So let's go to the Texture 2D field, click the Select button, start typing in cave, and filter out the cave-sprites. We're also going to want to set a Tile Padding of 2 and 2 so that we're able to pick the tiles correctly inside of the tile picker. Now, let's double-click on the tile map, and you'll see we now have a single tile which is our brush. As we move around, we're able to actually move the brush so that we can paint. But everything looks a little bit too close. So in the Scene view, you can actually zoom out, and move it around, and by holding down Shift, we can go ahead and paint some tiles. In order to choose the tiles we want specifically, go to Window and select the Tile Picker. You can drag this next to the game tab, and here you can choose which tiles you want to paint with. And you can also zoom in to get a better preview of them. Let's go ahead and go into the jetroid folder, and look at the Prefab folder. Inside, we'll see all the objects we can use to build our game. Let's select the player, and drag him into the scene. Also, let's go ahead and move the main camera by selecting the Main Camera and choosing the Move tool. As we scroll down and look at the game preview, you'll see our main camera is still zoomed in a little too much. Let's change this to 30 so it's easier for us to work with. The camera will automatically change its size when we run the game. While we're in the camera, let's drag Player over to the Target and run our game. As you can see, our player starts falling, and we're unable to actually land on any of the tiles. The problem is that none of our map tiles have Colliders. And while we can continue to go through and add them by hand, it would be a lot easier to modify our map editor to do this for us. Before moving on, make sure to save your scene.

Contents