What you will learn
In this Unity tutorial, we will learn how to effectively utilize the game engine. Over the tutorial, we will learn how to use the Unity editor interface as well as how to navigate in the scene view. From there, we will learn how to import assets and how to create prefabs. Then we will shape our level even more by adding character controllers, colliders, lights, materials and physics. We will then finish the tutorial by learning how to use scripting in order to make our level interactive.
In this lesson, we're going to learn about object transformations inside of the Unity game engine. So let's go ahead and actually start creating our level here. So we're going to bring in some objects from our project folder, and drag them into our scene view. And then we're going to talk about how we can actually transform or move, rotate, and scale those objects in our scene view. So what I'm going to do is actually just kind of pull this down a little bit just to give myself enough room inside of my scene view. And let's go ahead and go to our meshes folder. And the first thing that I'm going to do is go to my floors folder-- or floor objects folder-- and bring in my floors. So I'm going to bring in this floor_1. Now, whenever I have this selected, we can see a preview of that object. And I can actually click and drag around just to kind of look at it. Now one thing that's important is, if you get on the underside of it, or you see the back sides, you won't actually see anything at all. So if you go ahead and go to your preview and you're not seeing anything, or it doesn't look quite right, try rotating it a little bit to actually see that. So let's go ahead and click and drag our floor_1 into our scene. And we've got a floor object, and what I'm going to do is-- you see that it's kind of orbiting around it kind of funny. So I'm going to hit F on the keyboard, and this will allow me to orbit a little bit easier. Remember, F is Frame Selected, so that will actually zoom the camera in on that object. Now what I'm going to do is actually go ahead and show you how we can duplicate objects inside of Unity, and this is very, very simple. We just hold down CTRL and we'll hit D on the keyboard, and you'll notice that it's created a duplicate of floor_1. So I can actually move this object out, so now I have two of these objects here. Now, while we're here, let's go ahead and talk about snapping objects together. So if I hold down CTRL, and I grab my Move Tool Handle, or my Transform Tool Handle, I can actually snap this to a location. Now you'll see that this lined up pretty well right on my object here, and sometimes it doesn't actually work that well. So what I could do is if I want to actually line objects together right on like vertex to vertex, I can actually use vertex snapping. And the way this is done is actually holding down V on the keyboard. Now whenever I hold down V, you'll notice that my move tool has moved to the nearest vertex to my mouse. Now I'm still holding down V on the keyboard, and if I move my mouse along you'll see that it begins to snap to a vertex on my object. If I come way out here, you'll notice it is not going to this next object, it is staying constrained to this highlighted or selected object. So what I'm actually doing here is choosing the vertex that I want to actually snap. So what I'm going to do is actually choose this one way up here in the corner, and then I'm going to click and hold on my mouse. So I'm just going to click and hold the left mouse button, and move over to my object that I want to snap to. And if I hover over the vertex that I want it to snap to, you'll notice that it snaps perfectly to that object. So let's go ahead and actually start creating our level here. So I've created a single floor, and let's go ahead and actually just delete one of these just for right now. So I hit delete, you'll notice that that's gone out of the hierarchy. It's still in our project folder, so you don't have to worry about these leaving out of the project folder unless you actually highlight it and hit Delete. So let's go ahead and build a section of our first hallway here. So let's go ahead and go to our walls, so let's go to Wall Objects, and I'm going to choose wall_1. And here's my preview of what that wall looks like. And let's go ahead and click and drag this into our scene. Now what I can do from this point is go ahead and use that vertex snapping to get it right down on my object here. You'll see that I've dragged it in and it's quite a bit higher than my floor object. So what I'm going to do is actually hold down V again, and you'll see that my Move Tool snaps to a vertex on this object. And if I click and drag and hover over about where the vertex I want it to snap to on my floor object, it'll go ahead and move there. So now this has snapped right on to my floor object here. So let's go ahead and let's actually put a ceiling on this. So let's go to our ceiling objects, and I'm going to use ceiling_1. Now here's a great example of that preview not showing anything. So what we need to do is just kind of click and drag in orbit, and here we can see our ceiling. So I'm going to click and drag this into my scene, and you'll see that it's only giving me this little strip of my mesh. And that's because we're viewing the back side of the mesh. So if I rotate underneath, here I can see the ceiling. And so we're going to keep using that vertex snap. And if I want to get a little bit closer, I can go ahead and just drag this around. And let's go ahead and use this vertex on this object, so I'll hold down V, and then put it right up against that the back side of this wall object here. Now you'll notice that this is giving me just a little bit of a gap here, so what I'm going to do is just kind of pull this down a little bit. Now, I could hold down CTRL and snap this if I want to and it'll snap a certain increment. But you'll notice that this is going down a little bit too far. I only wanted to go down just a little bit, so we're having a few issues here. So if you don't like the increments that your object is snapping in, we can actually go to our snap settings and configure this if we want to. So I'm going to go to Edit, and at the very bottom we have Snap Settings. And this is going to bring up our snap settings dialog box, and we can actually adjust these increments here. So I can click and drag this down, or I can actually type this in. So what I want to do is go ahead and do 0.25, because one was a pretty long distance so I'm just going to do 0.25 on this. And you'll notice that we have scale snapping as well, and then we also have rotation snapping. So rotation is going to be every 15 degrees. So if that's something that you want to do, go right on ahead there. So if you want to switch that to 10 or five, you can go ahead and set this up all you want to here. So let's go ahead and close this out. And now if I hold down CTRL and I bring this down, you'll notice that it's not snapping quite as far. So I'm just going to bring it down to 0.25 there, and I might even bring down a little bit more-- and we'll just say 0.25, right about there. OK, so let's go ahead and let's do our next thing here. And what we're going to do is we're going to create a prefab. But before I do that, I want to actually show you how to actually rotate an object and then scale an object. So this is very, very simple. So if I just select my ceiling here, if I go to Rotate I can actually rotate this around. And if I hold down CTRL, this will allow me to use my snaps. Now rotation does not allow you to do vertex snapping. There's really no way to actually rotate a vertex snap. And then we have Scale which will allow us to scale in any axis that we want, and all three axes if we want to do that. And if we want to snap this, we just hold down CTRL. So just to kind of recap, if we want to snap any object we hold down CTRL. Whether that's using the Translate Tool, the Rotate Tool, or the Scale Tool. Now, if you're not used to the term Translate Tool, what I mean by that is the Move Tool, if that's something that's a little more helpful for you. So if you want to use CTRL to snap, you do that. Now if we're going to do vertex snapping, we're going to hold down V on the keyboard to do so. So what we're going to do in our next lesson is actually talk about how to create what's called prefabs. And these objects that we have here are separate objects, and a prefab is where we can actually group them together and make this build process a lot faster. So we're actually going to do that in our next lesson.