Join Adam Crespi for an in-depth discussion in this video Using modular elements, part of Level Design Basics in Unity.
With our level design fairly together in the 2D map, it's time to think about the modules in 3D. What we need to do once we got our map roughly laid out is to get together a working prototype to see if the sizes, heights and placements actually work in 3D. It's an important step before we get to the detailed art. It's very easy to jump into the art side and start making things we're going to use. But we need to hold off and plan a little more first. That way, when we make the art, we're doing it in the right place.
This map is designed in a modular fashion. We can see the repetitive elements in here. Three different small stores, and one long store. Plus the other parts. I'll jump over to Maya where I've created some rough prototypes and gotten texture sheet example on them. To start to assemble my modular pieces and see what else I need. Here in Maya, I've got a rough collection of parts I'm going to use. I'll go full screen by pressing Ctrl+spacebar so I can see a little bit more of what I've got. There's three store fronts without their stores as it yet. Each one is been mapped with a text or sheet and in this text or sheet I've added checkers and put in the names of that materials.
Obviously, these are made of plastic. There's walls next to it made of stone and other archways. Here's how I have laid out a modular, model sheet we'll call it, of pieces that are prototypes to test if it's working in game. The idea is I'm going to take each one of these pieces, such as this wall here, export it out uniquely, and bring it into unity, where I can make a prefab. Then If I re-export the FBX later, it will update in those prefabs with my detailed art. To start with, I've got three store fronts.
One with a very wide door, one with a narrower door, and one with an arch. I've also got two wall sections, one with a solid wall in the middle, and one that's ready for columns of some kind. What I've also created to join these, based on the reference imagery area a series of archways. A flat arch, curved arch, and narrow door. Designed to fit in these are two different door conditions. There is a rectangular door and a curve top door each with a frame and its own wall. With this lens being a modular approaches this.
If I've got a wall and I need to simply pass through an opening I can. If I want to take that wall and into it land a doorway, I'll press Ctrl+D. W for move and slide this over into place. I can have just like this a wall with another wall and a door way adding additional detail in my game and providing either a closure naturally to an environment through a locked door or a pinch point where I have to do something to get through the door. It gives me for two modules actually three different parts to use.
These are made to fit together. And I've given myself, in the design of these modules, some flexibility. As we can see in the back of the door here. There's a little bit of wall space next to the inside wall. So if I take this element, and slide it to one side or the other. I have what feels like a different condition. I can center it, giving me that indent on both sides. Or pull it forward right up to the edge of that wall, so it's a small shadow line on one side and a deeper on on the other. I'll delete that extra element for now as I already have one saved off to the side. Then, what I've done is to create a series of volts in here that I'm going to use in my narrow winding streets.
This will also help me with my spawn point. There's two sets, and they're labeled here. And I'll press Ctrl+A to go the Channel box or Attribute Editor to see this. This one is called Vault S Circle, Single B1. Vaults meaning semi-circular, as opposed to pointed. Single, as in, it's a single module B, 01. There's also A01. With the intent in here of having this geometry unwrapped in the same way. But moved on the texture sheet to a different place. Maybe one is done in plaster, and one is done in stone.
And it's a simple matter of choosing which one I want, and applying the right material. I've got double vaults as well. Because the texture should span. And that let me save some parleys across the middle. And finally, I've got end caps. These are just round half domes with extruded walls that are meant to snap perfectly onto the end of the volts. So I can have a logical end and small niches if I need. I'm ready to try assembling this and to see if my pieces work. I'll see if in this kit of parts I need any extra modules along the way. What I'll do to start out, is bring these over into Unity one at a time.
An I'll show it with a few of them. What I'm going to do, is provide for you, an export of all the pieces as FBXs uniquely. So that way, if you're not running in Maya, you can still pull-up that full collection, an use it in Unity. Here's how I'll handle the FBX process. First, I'll select all of my objects except for the doors and center the pivots. I'll choose modify and center pivot. I'll also zoom in on things like this awning and make sure it's all one object for now. This awning is a good example of using multiple materials.
Where I'm going to have let's say wood on the supports but the fabric here may actually vary because I have multiple fabrics designated on my texture sheet /g. I'll start out with my wall taking the first one Storefront C01 and choosing file, export selection. I'll export this out as an FBX file. And export out the selection, I am going to put it into my scenes folder, its a good idea when you are constructing a prototype like this instead of exporting straight into the Unity assets folder you export separately and drag over selectively just the pieces you want one at a time.
Although its an extra step it will help you stay organize as very quickly we can end up with a lot of parts. This is a simple scene and I'm already into nearly 20. I'll call this one exactly as it's named here in Maya /g, Storefront C01. In my FBX I'll make sure I go under geometry and include smoothing groups which are my hard and soft edges in Maya /g. I'll scroll down and there's no animation and or cameras or lights so, I don't need to worry about that. But, in advanced options under units I'll uncheck automatic and export out converting to meters.
This way I can put a scale of one in in the FBX although the prefab may show differently I know it'll be in the right size when it comes in. I'll click export selection, and run through the rest of the objects. Showing what it looks like in Unity when I'm done. Here in Unity, I've created a new Unity project called 03 Unity, in the chapter three folder in the exercise files. This way, it's a clean new project that I can bring my pieces into to assemble. I'll make sure I bring in the map I had earlier.
But I'd like to keep these projects separate from my research projects so I don't have any carryover accidentally. I'll start out by copying those fpx's into the assets folder and I'll see them automatically import so I can get them sized correctly. The warning at the bottom here on the Unity mesh triangle is one we can discard. Its only talking about a set triangle preference that may or may not come with this particular version that we can ignore because it was nothing its referring to in the scene. Here in my Maya project in my scenes folder are all my fbx's.
Each one being a separate object or separate collection of objects in the case of the doors. So, this way, eventually it can be a prefab. A prefab for us in Unity is something that is defined once. Objects, materials, lights even scripts and colliders, and then instanced throughout the scene. So, all the instances refer back to the original definition and we can turn on our Occlusion culling and reduce our draw calls way down. I will select all my fpx here and press Ctrl+c to copy jump over to my 03 Unity project and paste those into assets folder here in Unity in Assets folder. I will paste in those FBXs when I will switch back to unity it will automatically import those FBXs in back here in Unity, all of my parts automatically imported. What I'll do for each of them is select them and set the scale to one. Because I exported out as meters, Unity's scale being meters means the scale factor needs to be at one.
And for now I can check Generate Colliders. Alternately I could go through and put on Box Colliders in some of the objects. But as I'm going to come through and streamline the colliders later generating the colliders is fine. This is not a pretty level necessarily yet. So, I'm not going to worry about my light map UVs. A second set of UVs for light mapping that automatically flattens out the object for rendering the white into a texture. Because this is not the final art but instead a prototype I can ignore that. I'll scroll down to the bottom and click apply.
I'll make sure I do this for all the parts setting the scale to one and generating colliders. I'll finish this and then show some organization here in my project folder. Now, that I've got all of my fbx's set at a scale of one and all their colliders are on. I can start to think about assembling them on a ground plane. I'll start out by creating a ground plane, choosing Game Object > Create Other > Plane. Most likely, I'll end up replacing this ground plane with custom made ground elements later. But this'll give me a zero line to snap things to initially. What we want to do is actually vary our height and our terrain slightly keeping it reasonably flat and saving our slopes in slope colliders for things like stairs. Snapping onto a zero plane initially is good and then later it gives us the flexibility to rise up and down by moving both buildings and passing a ground through them.
The terrain object is something I'll reserve for, actual terrain that flows, such as the desert sands for example, outside this city. I won't use the terrain in here, because it tends to be a bit, soft looking next to the buildings, an I'd rather have the control to model unique pieces. I'll begin by assembling my vaults, and seeing what special cases I need. Here's how things snap together in a modular fashion. I'll take my end object, my vaults, circle pair. And drag it into the heirarchy. I'll press F to focus, and here it is in the view. We can see that the default Unity plane is actually quite small. I'll pick this plane and bring it scale way up maybe 100 by 100 by 100. Now, I can pick this vault object, pull it up, press V to snap to one of the corners and snap it down onto the plane and I'll start to assemble some of the ends on it. I can drag straight into the scene but it may come out below the ground. What I'd like to do, typically, is, instead of dragging it that way, I'll drag it straight into the hierarchy.
And this way, it'll appear exactly in the space it is in mind, next to the other pieces. And I can slide it around. I'll focus in, and see how this looks to snap on. What I can do is changed from textured wire to wire frame for example. And that's going to tell me a little clearer where I can snap to. I'll press V to snap, and snap this right in, and we can start to see our space taking shape. I'll do this by pressing control D, press E to rotate, hold control, and snap evenly. There's a 90 degree snap. If you want, you can go in here in the inspector and even that out, making it a perfect negative 90.
Now, press w for move and snap this piece in. We can see very quickly when I switch back to texture for example that we're going to need more elements. Although my vaults look good already, I've got two of the same ends here. The height works though. And more pieces will probably look pretty good in this modular design. I also need to make the dome, that's our spawn point and then I can bring in my map and start snapping these together. It's a good exercise though in modular parts to take them, bring them out as separate fbx's and bring them into your game engine in such as Unity and really see how they look when you assemble it.
I'll add on one or two pieces to see how this works. If I take my vaults and clone it by pressing Ctrl + D. Slide over, zoom in and snap together. I've created a column and it's good, but I'm kind of limited by these pieces, and this is why. In my creation here all my objects, I made singles as well. I can take a single vault and drag it in, zoom out and snap it on. And I'm starting to make a collection. What might be easier also is to look at it from the bottom view in a wire frame. Dropping down and choosing wire for example.
And now I can see my pieces and snap them. When we bring things into Unity, we need to remember that they are single sided. And so, we need to look at them in the right view to be able to tell where we are. Because these vaults are all made to face down, we need to see them from the bottom and we can start to Clone and Snap. What I am looking for is I am snapping these pieces out is that I am creating a space that is asymmetric, that when I walk through it's got a good flow to it and I don't part fatigue from seeing the same piece over and over. Here is the final test of my modules.
I'll drop a player controller in, going under standard assets characters, and here is my first control, which I'll pull right into the scene. Pull it up and make sure I check it out in a textured or texture plus wire to see if I'm seeing in the right place. When I play my game, what I see here, aside from a lack of light is that kind of neat rhythm in my space. I'll get out of this and just put a light in. One of the things we can do is just light up with a Directional light to test. Alternately, we can put material on everything that's simply unlit.
I'll choose create other and directional light, and pull a sun up in the scene. It's not any particular sun yet, but I'm at least going to angle it over and then press play again.and now here I am in my vaults. I've got a good height and size going. And it really feels like I am starting to be somewhere. I can see very quickly how the same wall shows above and over, and so I need to take into account my modules that more pieces would really help you. It's working though, and I have got a good travel and good sense of scaling the modules.
So, the quick prototype test of these is holding up so far.
Note: This course places a strong emphasis on modular construction techniques and resource optimization as part of the design process, which will help your build process be more lean, nimble, and efficient. A basic knowledge of Autodesk 3ds Max or Maya, and Adobe Photoshop is recommended.
- Setting goals for the player
- Planning the player path
- Bounding the world invisibly
- Defining player scale and field of view
- Using and joining modular elements
- Setting up prefabs
- Adding ambient animation
- Opening doors
- Making stairs walkable
- Lighting scenes