Join Craig Barr for an in-depth discussion in this video Placing modular assets, part of Unity 3D Essential Training.
- [Instructor] If you've followed along with the project, we have some assets ready to go to assemble our levels, so what we want to do now is start to build the overall level. We're going to take advantage of using different things like our Prefabs to be able to rapidly populate the level with our basic environment. So, let's take a look at placing the walls. So, we'll start here by placing some of the walls using those Prefabs. So, if you're following along with the exercise files here, you'll see that I'm using 06_01, and we are going to use Prefabs. This is a brand new, clean, fresh scene, and essentially, what we want to do is start to place these objects in scene.
So, in the Assets folder, I'm going to jump into my Prefabs, and I'm going to start to use some of the basics here. I'm going to take this corner and drag it into the Hierarchy. If you recall, what's going to happen here is if I were to take this corner and bring it out into space, it's kind of floating around based on wherever I want to drop it. Dropping it in the Hierarchy is going to place it as to where I created that back in my 3D content creation package, which in this case was Maya. So, I'm going to use this side wall here, and I'm going to do the same thing and just place that in the Hierarchy as well.
So, you can see that these two line up already. And if we look here, there's also something else that's key, and that is that both of these Prefabs are set to the origin. This is going to help us out enormously with placing our objects. Now, I can start to do a couple of things. As you recall, when we create objects, we can start to simply populate the scene by dragging and dropping them into the Hierarchy here, and that's what I'm going to do. I'm going to place these in a couple of different ways. So, even though we have that origin on there, that doesn't prevent me from using another really handy trick.
If I move this guy out of the way, I'm just going to zoom in to one of the corners on here. I can hit V, and what V will do is grab a corner point or anywhere that I want to use, any vertices on here. This case, I'm going to use maybe one of these corners here. And just by holding down V and dragging this, I can snap it to that other corner. And you can see how quick that is to be able to place that in there. So, let's place a couple more. I'm just going to drag a few more of these in. I'll just place one there, and then I'll place another one right here, and then, we do want a corner that I'll just bring out this way.
And rotate that guy by, let's see here... Probably about 90 degrees. Just change that to 90 which is fine, and then just move it over and place, so I've just quickly placed those in scenes simply because I want to do what we just did there before, and that is zoom in, hold down V, and grab a corner and snap it in place. And I can do the same thing with all of these as well. And take this guy, use that corner, and snap it in there.
Now, when we want to deselect, just grab or just click somewhere in the Hierarchy, so you deselect everything. There's our basic one side of it, right? We have our pipes. We have our railing. We have a floor, and we have a ceiling up above, or a roof up above there, as well. So, we have all these little components that if we wanted to piece them all in here one by one, that could take some time, right? This is something else that in our 3D content creation package, we could build all as one complete set. There's no reason why you couldn't do that, and export it as an .fbx, but I really wanted to show here the ability of rapidly reusing Prefabs and how we can create your own scene.
So, with this, I'm going to create, essentially, a rectangle. You could, by all means, go crazy with this and create tunnels or whatever it is that you may want to build on here. Now, I'm going to place in a couple other pieces in here, so I'm going to put a side wall, two more side walls in here. I'm actually going to delete this one because I'm going to just take this one here and rotate it in... We want to go negative on it maybe, -90, and then just be able to bring that up into here and if you recall, we just zoom in and take our V, and find that snapping point, there we go, and then what I can actually do with this because I've already rotated and placed that.
I can hit Ctrl+D in the viewport or in the Hierarchy. And then, bring this over in here as well. So there's a really quick way to just duplicate, you know, kind of saving your efforts there, if you've already placed an object in the scene. So that's looking pretty good. We have things coming over and looking nice. At this point, what I'm going to do because everything's starting to look pretty cool in here. I'm actually going to turn the grid off. So you can see the grid over the top of our textures. If we go up to Gizmos, I'm going to click Show Grid, so I've turned that off, and just keep populating this scene here.
So, we've actually built that, and you've seen how I can duplicate that. Well, what if we wanted to do that with an entire side of things? We can, so let's actually get rid of this one here and grab all of these guys. I'm just going to box-select that. Oops, want to make sure I'm not grabbing that light in there or the camera. So, just make sure you're not doing that. It might even be easier to do this actually in the Hierarchy, to shift-select everything there. Hit Ctrl+D. Now, this is important to understand here. In most content creation packages right now, what I would do is negative scale this you know, in zed, right, like this.
And then, I would freeze transformations on it, so I that I don't have to worry about that anymore. That's not going to work here, so what we actually want to do... The reason why it's not going to work is, it will work in here but collisions are going to have an issue with that, so you're better off actually rotating the entire thing around. We have a couple pieces here that are getting double transforms on. That's not a problem. We'll put them in place, but this way at least we have everything kind of rapidly rotated around, so I need to place my corner piece in here. I'm actually going to get rid of that corner piece, but I am going to reuse these guys.
So, I'll just place them over here. This one here, I'm going to rotate. Let's do it to, I think -90? Yep, and just move that one over here for now because we are going to snap all of that in place. Just bring that one along. And this wall in here, actually, we will get rid of and then I'm going to grab all of these guys. And we'll just bring it over here. I actually should have kept this same one.
Not a problem. I'll just hit V and snap it into place there. And then what I want to do is just make sure that all of these guys are going to line up, so I'm going to grab them all. Not that last one there, and then, I'm going to do the same thing on this giant piece. I'm going to hit V, grab a corner, and snap it based on that corner. So, there we go. We're starting to get this thing looking pretty good. We're starting to populate the scene. I'm going to drag in another corner area in here and maybe put that over to 180...
Will give us what we want, that's great. And, just grab the corner on this one here as well, and snap that right into place. So, there we go. We have a basis of this. Now, wait, there is one piece in here that I want to bring in. So, let's go over to Models, Environment we'll go into, and there's this thing called Gate. Now, it's funny actually, and the preview doesn't show the whole front of it here, but if you turn it around you will see it. So, I'm going to bring Gate in and actually snap it down there at the origin and then just bring it into view.
I'm pressing F to focus in on some of the things here. Now once again, I want to make sure that this guy is aligned to this opening in here, so I could just kind of arbitrarily place it in there, or what I can do... Let's just make sure that that is set to one, and I want this kind of halfway through the wall, and actually, that's pretty decent. It's already going halfway through that wall there, so that's pretty good, so if we step into the basics of our structure right now, you can see that we're starting to get a bit of an environment set up in here.
So, there's some of the basics of placing objects in here. As we move forward, we'll get into the rest of the scene in here including a lot of the key props that we're going to add in here as well.
- Setting up a Unity project
- Customizing the UI
- Navigating Unity
- Exporting and importing assets for Unity
- Creating and organizing new materials
- Creating, exporting, and importing prefabs
- Level building
- Creating and implementing animation
- Optimizing collisions
- Baking lighting
- Packaging your Unity project