Join Craig Barr for an in-depth discussion in this video GameObjects and asset creation, part of Unity 3D Essential Training.
- [Instructor] When it comes to the entire universe of Unity, there's nothing more important than game objects. Game objects really are everything within Unity. They are the essential building blocks of any project. And here we're going to take a look at what a game object is and how it works. So, we can see on the menu that up top we have this menu set called, Game Object. And this is where we can create anything really, for our scene, from 3D objects including primitives like we've done before here with a cube, and a sphere and a simple plane, right down to things like basic effects, lights, audio, video, user interface elements, elements for building your game and of course, cameras.
Now let's take a look at what game objects are and how they work. Well, you can see in the scene that we have a couple of objects here already. Whether I click on the camera and we look at the inspector or I click on the cube or the plane or this sphere for example. You'll see something in common with all of them and that is this basic structure here of a game object. It doesn't matter what I'm clicking on, they all have this in common, this top area here. They have a name or a label for what the object is that you're creating and they have a transform tab.
Everything below that is essentially what we refer to as a component. So, the best way to think of what a game object is, it is essentially a container to hold attributes or to hold parameters, or in this case with Unity, they're actually referred to as components. So how does this work? Well, to show this here, if we take any of these objects, we can see that we have the transform and then we have this series of what are referred to as components that actually comprise or build that object.
I think probably the best way to actually illustrate this is to create a blank game object and build it into, well, whatever we want it to be. So in this case here, I'm just going to go to game object and I'm going to click, Create Empty. And you can see that the default name for it is game object, here. So if I want to change this name to something that I'm going to create in here, I'm actually just going to highlight this and maybe change it to, MyCustomLight.
So you can see I've started out with something empty. There's nothing here. This would be comparable to something like a locator or a null to a certain degree, much like you would have in a 3D content creation package. It essentially is nothing with a transform. But it's more than just nothing, it's actually this container where we can turn into, well, whatever we want it to be. And in this case here, I'm going to create a custom light. So I'm going to go to the Add Component, and you could see that if I drive down inside here, I have all these different areas that I can access things.
So I'm going to click on Rendering and I'm going to click, Light. And if we look at this before I start dialing this into what this is, this is pretty much what we're seeing here on our directional light, you see that the directional light has a light component and it is being defined as a directional type of light. Of course, things like color and different modes or anything may be set in here as well. The directional light has a default transformation applied to it. Let's go back to, MyCustomLight. I can position this and set this wherever I want it to be and of course, I can change this to whatever kind of light I'd like it to be in here as well.
So, the important thing to understand here is the way that this works. If I want to create anything, it is based on this idea of this container called, the game object and then we add in components. Now if we take a look at something like the Cube, by default, any primitive that we create, will all have a collider on it. And that's the physics based on it that we can see with the sphere as well, it'll have a sphere collider and that essentially will represent the overall volume or shape of that so that we can collide with this automatically and we don't have to add that.
By default, anything created under game object, 3D object primitives is going to place a collision around it. Of course, that doesn't mean that we're stuck with that, at any time, I could go in and add maybe perhaps, a different version of that, if I wanted to put, say for example, a mesh collider here and actually remove the default box collider that comes with that. We'll get into collisions a little bit later, but a mesh collider essentially, is going to calculate a collision based off of the size and shape and volume of the object in there. The point is this, that it's important to understand how Unity works and once you understand that, you'll really see the power of what Unity brings forward to all of your projects.
This idea of a game object being a container to store any number of attributes or parameters that you need. So, another example in here, we looked at creating this simple custom light. If I take something like our sphere, it's an object, it's a piece of geometry, in it has a collider, as you've seen on here. The mesh renderer component is how that will be rendered in game view. So, this mesh renderer says, render this based off of the lighting and materials applied to it, so that I can see it in game.
Well, the cool thing about this component based system is, like I said, they can be anything you want. So for example, I could add on here, something like an effects particle system and by default, we're going to get this sprite based system off here, I can go in and actually dial this in and define what I want it to be. We're going to dive in quite deep into particles a little bit later on. But the point is this, that we can create anything we want with this idea of game objects here in Unity.
So it's important to understand, like what I've shown in here, this ability to create your own whatever and make it into whatever. But it's also very important to understand that everything that we place here in Unity, is essentially a game object that has the series of components or parameters in there, that will allow us to store all of this data. And it's unlimited, as mentioned, it can be light data, it could be collisions or animation or perhaps, scripts. It can be anything related to how our game or our project is being assembled.
So there's an overview of game objects as they apply to Unity 2017.
- 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