In this video, you will learn how to use the Pucker and Bloat Effects in...
This video demonstrates how to add weapons in UDK.
Welcome to Basics of GameObject Creation in Unity! In this tutorial, we'll be learning:
We'll also be putting all of our new skills together by building a 3D house like the one pictured in the image below.
To complete this tutorial, you'll need:
We'll be importing an asset from this tutorial's download folder into your scene, so if you haven't done any asset importing yet, you may find it useful to check out the Importing and Exporting Assets tutorial before moving on.
Now let's create a fresh new Unity project and get started.
When building scenes in Unity, they will often be constructed primarily out of GameObjects. Any object in any game that you develop is a GameObject — they can be 3D shapes, particle systems, GUI objects, lights, and even cameras!
Every GameObject that you use begins its life as an empty GameObject, like the one pictured in the image below.
Then, components are added to the empty GameObject. Components can be anything from textures to scripts and animations! One by one (or occasionally all at once), components are added, transforming each GameObject from something empty and lifeless into something totally amazing!
Now that you know a little bit about GameObjects, let's make some!
Creating a simple GameObject is very easy, and there are many ways to do it. To start, let's create a GameObject by going to GameObject (on your Unity menu bar) → Create Other → Cube.
BOOM! Your cube GameObject appears. Isn't it nice, with its cube-ishness? Note that once your object has been created and placed in your scene, it will be visible in your Hierarchy panel.
Now let's see what we can do with our cube.
Each basic shape GameObject that you create will eventually have its own characteristics that make it unique and useful within your scene. However, 3D shapes will always start with four unifying components:
We'll be going more in-depth with Mesh Filters, Colliders, and Mesh Renderers in later tutorials. For now, lets' look at Transforms.
In Unity, there are three different types of transforms: Position, Rotation, and Scale. These transforms can be modified on each of the three axes visible on the Scene Gizmo, shown below.
The first transform we'll be looking at is Position. In Unity, the Position of a GameObject is where it resides in 3D space.
Rounding our numbers, you can see that the cube in the image above is located at roughly:
These numbers correspond relative to the center of 3D space in our scene.
In Unity, a position value of 1 is equivalent to 1 yard. (1 yard = 3 ft.)
You can modify the position of an object either mathematically by placing your numbers directly into the value boxes for each axis, or by putting your GameObject into Translate mode (click on the object and press W) and moving it visually by grabbing any one of the handlebars of the GameObject's gizmo. Note that each handlebar on the gizmo has a color, corresponding to its matching axis in the scene gizmo.
Why not try moving your new cube with the gizmo now?
GameObjects can also be moved by clicking and dragging the center of the gizmo, but that method is usually not accurate in all three axes at the same time.
Where Position determines our GameObject's location in 3D space, Rotation determines the angles at which it will sit within our environment. Just as with Position, Rotation can be modified on each of the three axes, either mathematically by placing values in the Rotation fields (x, y, and z) or by accessing the GameObject's gizmo in Rotate mode by clicking on the object and pressing E on your keyboard.
Although you can really only rotate on each axis up to 360°, you can put any whole number (positive or negative) into the text fields for Rotation. If the number is greater than 360, Unity will divide it by 360 and then rotate your object based on the calculated remainder. (Isn't that nice? Unity does math for you sometimes.)
Scale allows you to resize your GameObject on any axis. This can be done either in the text field for Scale or by using the gizmo in Scale mode, which you can access by clicking on your GameObject and pressing "R" on the keyboard. Every GameObject begins its life with a scale of 1 on each access, which is then multiplied by whatever number is placed in the text field.
Now that you know how each of the transforms function, let's put them to work by building a wall for our house!
To begin, let's move our cube to point (0,0,0) in the scene. Working like a 3D graph, that translates to (X=0, Y=0, Z=0). Because we know exactly where we want the cube to be, it will be more efficient to move it by putting the number 0 in each of the Position text fields, instead of moving it manually using the gizmo handlebars. Moving the cube to the center of our 3D space is not required, but it may make the rest of the process easier to understand.
Did your cube disappear offscreen when you changed its position values? You can find and focus on any object in your scene by either double-clicking on its name in the Hierarchy or single-clicking on the name and pressing the F key.
Next, we're going to scale our cube to give it the appearance of a wall.
Remember that a value of 1 in Unity's 3D space is equivalent to a value of 1 Yard in real space. To create a wall with dimensions of roughly 30 ft x 9 ft x 1 ft, we'll change the scale to (x=10, y=3, z=0.3). Let's do that now.
Now that our cube is properly set up to look like a wall, let's rename it accordingly. You can rename GameObjects by clicking on them in the Hierarchy panel or by clicking on their current name in the Inspector panel.
Our first wall is ready to go. Now let's construct the floor!
At first glance, you might be inclined to just use another cube to create your floor. This is actually a viable option, and you absolutely are allowed to do it. However, in terms of memory management, this might not be your best option. You see, GameObjects that have meshes are constructed of polygons. Every polygon in your scene must be accounted for, and every polygon in your scene takes up memory. A plane contains one-sixth of the polygons that a cube has, which can add up to quite a lot. Planes are also only visible from one side, which takes up less memory as well. When building floors, you will rarely need a floor that you can see the underside of. Therefore, using a plane is a much better plan than using a cube. Let's add a plane to our scene now.
In addition to creating GameObjects from the GameObject menu, you can also add them by clicking on the Create button in the Hierarchy and selecting "Plane" — let's do that now.
When your plane is first added, it probably will not be in the position that you want. Using the handlebars in Translate Mode, position your plane where you'd like the floor of your house to be.
Be sure to look at your scene from multiple angles by rotating (or orbiting), panning (moving in 2D space, up/down or left/right), and zooming around your objects. You may find that when things are aligned from one angle, they actually are not aligned from another. This is why it's a good strategy to align each axis individually. Here are some mouse controls that will help you get it done:
When your plane is set up correctly, your scene will look something like this:
At this point you may find it helpful to rename your plane "Floor" or something similar that will remind you of what it is in the Hierarchy. Once that's done, it's time to create the rest of your walls!
A standard Plane in Unity is 10x10 units. That's why we scaled our cube to 10 units long!
When creating a cluster of GameObjects that are similar (like the walls of a house), you have a few options available that are way faster than following the steps of creating a new object over and over. If you're creating a very specific GameObject with custom components or mesh, you're going to want to create a prefab (something we'll be getting into in later tutorials). For something simple like walls, you have an even faster option — keyboard shortcuts!
What we're going to do here is duplicate our wall, and it's going to be super easy! First, select the wall that you want to duplicate, then press CTRL+D (PC) or ⌘+D (Mac) to duplicate the GameObject.
The new GameObject won't be immediately visible because it's created in the same place as the original, but you'll be able to see that a copy has been created in your Hierarchy.
Next, move your new wall into place by selecting it and moving it in Translate mode.
Duplicate your wall again and position it in the middle of your plane. We'll be using this one for the back wall of the house.
Rotating the back wall on the correct axis will make it perpendicular to the other walls.
In the example above, the axis requiring the rotation is the Y axis, but it may be X or Z for you depending on the orientation you used at the beginning of the tutorial. It's not a mistake if you need to rotate along a different axis, so don't worry. Rotate your third wall so that it's perpendicular to the first two, then place it on the back edge of your plane, just like in the image above.
Once the back wall is in place, duplicate it to make the first part of the front wall.
We can insert a doorway to the front wall using a few simple steps. Let's begin by scaling our front wall to 35% of its original with. Change the scale of the X axis to 4.
Once the width has been changed, move your now smaller wall to one side of the house.
Duplicate the smaller wall and move its copy to another side of the house. The walls are now done!
Building a roof using standard 3D shapes in Unity can be a bit tricky (there are no pyramids or cones to work with), so it may require a bit of creative engineering. Fortunately for you, there's a file called roof.unitypackage in your download folder. Import the file as an asset package, then continue.
Can't remember how to import and export asset packages? Check out the tutorial on importing and exporting for details.
Once the roof mesh is imported, you can drag-and-drop it directly from the Project panel into the scene.
Rotate and place your roof just how you'd like on your house. Once that's done, your very first building in Unity will be fully constructed and ready for texturing! Great Job!
Web & Flash
Graphics & 3D
DV & Photo