[MUSIC] [SOUND] In this video, we'll set up a foundation of the first level of our game. Our objectives will be to create the base level for our game, including a floor and various obstacles, and then set up the layer. Along the way, we'll discuss prefabs, an important concept in unity. In roller madness we're going to use many of the prototyping standard assets. These are of course located in standard assets prototyping. These assets are basically geometric shapes that we can use to create a quick prototype of a game or as they say in game design. We can white box the level. Typically you would eventually replace the prototype assets with actual production game art. But for our purposes, with this project, the prototype assets will be our production game art. So, within this folder, you can see there is a Prefabs folder that has several prefab objects, which we'll talk about in a moment. That make up these geometric shapes. So it's a little hard to see down here in the preview. But you can see there's a block prototype four by four by four means four meters by four meters by four meters. If I just scroll down you can see there's blocks and cubes. There's various floor assets. I'm gonna use the floor prototype. 64 meters by 1, by 64. And go ahead and drag that into my world. You can see right there it's a fairly large game object now, right there in my world and I'm going to go ahead and rename this just Floor. And I want to position this basically at the origin of the world, zero, zero, zero. So we can go over to the transform of course and do that, notice that I've got a little rotation on this as well. One of the quick ways rather than entering numbers if we want to go back to the origin is just to reset this component. So any component you can actually reset back to the default settings or the standard settings so let me go ahead and click the little gear here in the top. Right corner of the component, and notice the top option is reset. So let me go ahead and reset that. You can see that I'm at position zero zero zero, scale, or rotation zero zero zero, scale one one one. So that, whatever you reset the transform component, that's what you get. Now, like I said the floor is a little bit big, so I wanna scale it down a little bit. So I'm just gonna go ahead and scale it half size in the X direction. You can see it made it half size. The Y direction, I'm just gonna leave at one. So that's the thickness of our floor from the bottom to the top. And the Z direction I'm also gonna go to 0.5. So I'm essentially half the size that it was in the X and the Z direction. Okay, now I want to add some obstacles to my level. So I'm gonna go ahead and continue to use some of these prototype assets. I'm gonna pick the floor prototype four by one by four, right there. Go ahead and drag it out. And of course I can tap the f key to zoom in on that. And I'm gonna rename this as Bumper, and right now it looks just like the floor because it's got the same material attached. So you can see the material over in the mesh renderer. You can see it's got the navy grid material. If I click that it will actually select that in the project, it's kind of a shortcut to find it. Down here where you actually see the material there's nothing to really click to jump over there and select it. So with the navy grid selected I'm gonna go ahead and duplicate this material. So I can just go up and say edit, duplicate or use the command or control D to do a duplicate. And I'm going to name this my bumper material. Now of course this put this in the same folder as the rest of the standard assets. That's okay because it's just a copy of the standard assets. It's my own copy for this particular project. If I wanted to kind of separate my standard assets from my actual assets, of course I could go up and just move this to the top level of the project as an example. So with the bumper material selected I want to change some of the properties of this. Most notably I want to change the albedo and the nap on it If I select this, you can see it's using the swatch navy albedo. I'm gonna use one of these premade assets, so I don't have to make time to make the asset. So I'm gonna pick the swatch teal albedo. So I can simply drag and drop it over here. And make that change. Now, one common thing that people sometimes make a mistake is they'll select something and then they'll click. And, of course, that's gonna change the Inspector. One thing that you can do is you can actually lock the Inspector. So if I click on the bumper material, I could click the little lock up here. To lock what is here. Now, if I click down here it's not gonna change what's in the inspector, so it's gonna stay on the bumper material. And then, of course, I can click, and then drag, and drop it, and make that change, and then, of course, unlock when I'm ready to unlock it. So I've got the material made, I need to apply the material to the bumper. So let me go ahead and drag and drop it onto the bumper. And you can see that that material is now attached, and we can visually see that. So the next thing that we need to do is, we need to position our bumper. So right now you can see it's just kind of where I threw it out there. Once again, I can reset the transform. Which is going to, essentially, put it at the origin of the world. And you can see it looks a little bit funny because it's basically at the exact same position as the floor. So I'm getting a little rendering problem here, where Unity can't decide which one it should render first. So this happens to be one meter tall. So I'm gonna go ahead and move it up one meter and you know you could do this visually once again. It's very hard when you're doing it visually to get exactly one meter. You could do it numerically over in the transform. One of the nice things in Unity is actually snapping option. So under edit I can bring up snap settings. So here you can actually set the snap settings. So right now it's set at one meter, by one meter, by one meter. And scale settings as well. So let's say I'm visually moving this, like here, and I've got it at 0.66 MOI, I could basically click this snap to the y. And it will snap to the closest meter so you can see now I'm at 010 or I can say snap all axes so let me just move it off and then say snap all. It's gonna snap at to the closest whole numbers here. Once these snap settings are set up you can actually hold the command key on the keyboard or the control key on Windows. And with that key held down, you can grab any of the axes and then move. And notice it's moving one unit at a time. So I'm gonna move this a little bit off center. You can move it in whatever direction you want with that key modifier, the command key or the control key. And it will snap to whatever the snap settings are set there. In the snap settings options okay, I'll go ahead and close the snap settings for now. So, we plan to have several bumpers in the world. Whenever we plan to have multiple game objects who are nearly identical we should make a prefab out of them. Prefabs are essentially a template of a game object that you can use over and over again. By making a game object into a prefab, you then only need to update the prefab itself. And then all the game objects that are built off of that prefab are updated. So the way that we actually create a prefab is take your game object and simply drag it into your project. And I'll just drag it here into this sort of open spot below my material. And it's gonna create the bumper prefab. I'm gonna go ahead and close standard assets for now just to clean up a little bit. So let's also make a prefab for the floor. So I'll show you another way of doing that. Under the project panel I can say create prefab. And this will make what's called an empty prefab. And I'll call this floor. Notice the bumper prefab is blue-shaded. That means there's something in the prefab, where this one is grey-shaded, which means there's nothing in there yet. So we can basically grab the floor, game object, and drag and drop it on that empty prefab, and then it will turn blue, okay. I like the technique of just dragging from the hierarchy over to the project because it's a shortcut. So now that we've got our bumper prefab created, notice that the game object now at the very top says Prefab, so it's connected to a Prefab. If for some reason it gets disconnected, it'll say Prefab missing here, in which case you need to resolve that issue. So I've got one bumper, let me go ahead and drag out a couple more bumpers. So, let me drag out a second one. Once again, I could go ahead and use my snap settings, so I'll bring up the snap settings and snap to all the axes. And I wanna essentially bring this a little bit off from that prefab, so I will hold down my command key and go ahead and drag that. And I freeform dragged it initially, so it did get off a little bit. So let me numerically set that back to seven. And let's go ahead and add a few more. Go ahead and use the Snap Settings. So I want all of them one meter high in the y direction. So basically I'll kinda create this little pattern, I can select all of these at the same time. Once again holding down the command key and then moving them sort of in unison. So I'm gonna kinda center them essentially on my world. So I've got four bumpers out there now. Let me go back to one of the bumpers. And I might decide later that, you know, these bumpers a little bit big so I want to scale them down. So let me select this bumper, and let's set the scale in the x direction at 0.5 and the z direction at 0.5 and of course I'll leave it at 1 meter tall. So I applied that to this individual game object so it's built off of a prefab but it's got these modifications now on it. Now if I make these changes, and I decide oh, I didn't actually want to do that, I can actually just click revert. So if I click that, it goes back to the settings of the pre fab. But let me go ahead and make those changes again. 0.5 and 0.5. And let's say that I do want to propagate these changes back to the prefab. I can go ahead and hit apply here. And notice that it applied it to the prefab, and immediately applied it to the rest of the game objects that are built off of that prefab. So this is one of the very powerful things of prefabs. So we've got a floor out, and we've got four bumpers, I need to get my player character out. So I'm gonna go ahead and close snap settings. For the player character, we're gonna use a standard asset. Under Characters, and we're gonna use the RollerBall standard asset. You can see they have a FirstPersonCharacter, a ThirdPersonCharacter, and a RollerBall. We're gonna go ahead into the RollerBall, into the Prefabs, and grab this Prefab. So that's essentially what they're giving us is Prefabs that are game object, templated game objects, that are all set up and ready to go. So let me go ahead and grab the RollerBall, drag it out here, once again I can bring it out, I can reset the transform to put it right into the middle of the world. If I click the F key and zoom in, notice it's actually cut into the floor. I'm gonna go ahead and hold down my command key and drag it up. I'm saying about 2 meters. So it's a little bit off of the floor to start with. And we've got that game object now in our world. And notice it's got a variety of components. Two of the most notable things is the ball script and the ball user control script. So this is what actually controls the ball. So, without further ado, I could just click play. And my camera's not set up yet, but I can use the WASD keys or the arrow keys and actually roll around this world. So, remember the difference between play mode and non-play mode, so I'm in play mode right now, so I can actually test things. I could click on various things, you know, in the editor see what's happening. But any changes that I make will not take place until I stop play mode. So let me go ahead and click the play button to stop play mode and reset back to the default settings. Okay, let's go ahead and save our scene now since we haven't done that already. I'll go ahead and save the scene as level one, and store that to our assets folder. Of course we should save often, all the time, as we work in Unity. >> Prefabs are a very important concept, so let's review. Once you set up a game object with all of its components, you can convert it into a prefab. A Prefab is essentially a template GameObject. With the Prefab, you can make additional GameObjects. The nice thing about GameObjects created with a Prefab is that if you ever update the Prefab, it will automatically update the GameObjects built from it. Further, you could customize a GameObject built from a Prefab. And then revert back to the prefab if you don't like the change or if you customize a game object built from a prefab you can then apply those changes back to the prefab so that all of the other game objects built from that prefab are then updated. Prefabs are a very powerful tool when building games in Unity. Without understanding how they work, Prefabs can also pose a major problem for you. We will continue to use Prefabs across this project to help reinforce how they work. In the next video, we'll set up the camera. [MUSIC]