Level design is one of the most fun parts of game building. In level design, we get to take the assets we've made and, well, construct a level, putting in things for the player to encounter, such as our snapping crane here or engine. We can also put in doors and doorways to strategically bound the player into rooms. We can direct them along and give them other things to see, buy maybe not get to. A good prefab structure makes for easy level design. Once we've got our prefabs made, we can instance them in and retain that prefab connection, cloning those parts out and simply building our level on the fly, constructing out the rooms we need, and pressing Play quickly to test.
What I've got so far is kind of a working scene. I've been dragging things in to be able to test things in here. I've got an archway on a floor, which is, well floating above my plane. A snapping crane, and another crane that swings over. An engine, conveyors, and so on. I'm going to take these objects and delete them. Selecting them, and holding Control to deselect the first-person controller in the hierarchy, and pressing Delete. These are prefabs. I've dragged them out from my prefabs folder so I'm not going to lose a connection here. I'll also delete my plane. The plane is a unity object, created by choosing by choosing Game Object, 3D object and Plane There's some basic primitives in here: cubes, spheres, and so forth, that we can use as part of our level if we need, if we need something flat with simply a material on it.
As an alternate, they're great for prototyping. There's actually a standard package for prototyping of more distinct objects if we need. But these are always handy. With the plane deleted, I'll start to bring in some prefabs. Looking in my prefabs folder I've created in my assets folder, I'm going to lay out the floors for my factory. My though here is we want a few rooms with some machinery in them. Maybe a couple medium and a large room, and some hallways connecting, all defined by these floor plates, and then walled in, and joined by my doorways and archways.
Then I'll go through and populate with my cranes, machines, crates, and boxes, really fleshing out that level. The goal in this game is to simply get through without being knocked by one of the machines. I'll start out, then, by taking my floor corner prefab and pulling it into the hierarchy. I'll press F to frame in, and we can see this comes in at zero-zero. That's because this is where it was exported from 3ds Max. What I'll do is to bring in some more elements and start to snap them together. I'll bring in the floor wall border and, again, pull it in, and this time pulling it right into the scene.
Then I'll snap these together. We have a choice about how we're snapping, and where we're moving from. If we press and hold V, as in Victor, we can position that transform handle on the mesh. And then, snap these together. That transform handle snaps back to the center, because I've chosen up at the top: Center. I'll go back to Pivot, and now it sets down at the pivot where I had set it. We also have a choice in here over global or local rotation, and we can see the change in those axes as I toggle this. I'll switch back to local, press E to rotate, hold Control, and click and drag on the blue z-axis to rotate this over.
I'll zoom in, press W to move, V for snap, and snap right on the vertex and pull these together. It's important to look around and make sure that all of your elements are snapping as much as possible, as this will help later with lighting, and also avoid unsightly voids in the game. Now duplicate this along, pressing Control + D to duplicate, and V for snap again. I'll snap this into place, and I'm starting to build out my floor. If you'd like, you can switch over from Shaded to Shaded WireFrame, which shows the WireFrame on your objects if it's easier to see where to snap to.
I'll duplicate this a couple more times and then duplicate around other corners and really get this first room together. I've cloned out my floor, creating a three-by-five module section of my factory, and I've left a space open in the middle for my elevator. I'll drag this in. And this is just really decoration. It's not functional as an elevator to transit between levels in here, but just really something in the floor to bump into. Now that that's in, I'll start to bring in some of my archways. I'll take archway A, and I'll pull it into this scene.
We can see as making part of the prefab here that it's off-axis, but that's not a big deal. I'll go into the rotation and set that back to zero and zero on the x and y. I'll leave the z at, well, it should be probably 270 to spin it around the right way. Be careful of which axis you're rotating on. That z actually pulled it around in the wrong direction so I'll return it to 90 and spin a different way. And we can see in here the difference between local and global. I'll switch over to global, and we can see I should be rotating on the y-axis.
I'll spin it around, holding Control and clicking and dragging on the y-axis, and now it's in the right direction. And I'm going to take this archway, and move it over right in the middle of my floor at the end. Press F to frame in, zoom in, and snap it in place. I'll switch over in this case to WireFrame so I can really see what I'm doing clearly. And I'm going to snap this object right onto that floor, letting it lap over that bump in the flooring. I'll press V for Snap, and snap this archway right in in the end.
They're made to fit together in this kit of parts. I'll make sure it's snapped in, registering right here on the vertex, and pulling it in. I'll nudge it over just a little bit, adding in a little bit of variance in here, and that really helps along the design. I'll continue to bring in my prefabs, starting out with the environment, and laying out the level. It's as simple as dragging in, either from the prefabs folder into the hierarchy or straight into the scene. We'll start to see very quickly that my level is emerging, and we start to get, well, the first goal: to get through that door, showing
- Setting up the project
- Creating a player controller
- Importing assets, including models, audio, and textures
- Generating colliders
- Creating prefabs
- Applying materials
- Creating animation
- Designing a basic game level
- Lighting the level
- Creating particle systems
- Adding audio
- Building the game for desktop or mobile deployment