Feu Unity 3 D Lesson 1
Feu Unity 3 D Lesson 1
Page 1 of 17
Illustration 1: Unity comes with an IDE for developing games visually, in a rapid-
prototyping approach.
After checking it, close the Preferences Window. Now, whenever you start Unity, it will open a dialog
window to let you choose which project you want opened.
Now we'll open the Lesson 1 project. If you haven't downloaded the LessonAssets zip file, do so now.
(Can be found at https://dl.dropboxusercontent.com/u/25260770/UnityLessons/index.htm). It contains
all the necessary files we'll be needing for all the lessons. Inside that zip file is the Lesson 1 folder
that we need to open.
There are two ways to open a Unity project.
Game Programming Using Unity 3D Lesson 1: Introduction To Unity. Page 4 of 17
If your Unity Editor's window title says Untitled, make sure to open the MainScene file from the tab
that says “Project”. Double-click that file.
Now to ensure the layout of your Unity Editor is the same with the rest of this lesson, change your
layout by choosing Window > Layouts > Tall in the top menu.
Game Programming Using Unity 3D Lesson 1: Introduction To Unity. Page 6 of 17
1. Scene View: This shows a view of your 3d world. In Unity, the 3d world is called a “scene”.
2. Hierarchy View: This shows a list of all the objects in your scene. In Unity, objects are called
“game objects”.
3. Inspector View: This shows detailed information about the currently selected game object.
Game Programming Using Unity 3D Lesson 1: Introduction To Unity. Page 7 of 17
4. Project View: This shows all the resources that your project can make use of. This ranges
from source code to 3d objects, images, sounds, fonts, and other files.
5. Toolbar: Various other buttons to interact with your project.
Focusing On An Object
In your Hierarchy View, find the object named “Simple Cylinder” and click on it. Now move your
mouse cursor to the Scene View. Press F on your keyboard. This will center the camera on the
selected object.
While that object is centered, rotating the camera will rotate around that object. Once you pan the
camera though, the object won't be centered anymore.
The three arrows are handles to let you move the cube. The red arrow lets you move the cube left
and right. The green arrow lets you move the cube up and down. And the blue arrow lets you move
the cube forward and backward.
Simply drag these arrows to move your cube Distance in
back-and-forth in that direction. Unity is not
measured in
To move the cube freely in any direction, drag any particular unit of
from the white box located at the center of these measurement, but by
default, the physics engine
three arrows. assumes the distances are
measured in meters.
When you move your game object, look at the
Inspector View. You'll see there the numerical
values that denote the x, y, and z position of the
game object.
Those are text boxes, so you can type the exact value you want. You can also cut/copy/paste them.
You can also edit the x, y, and z values with your mouse. Just move your mouse on the label and then
drag.
You'll see the three arrows change to three arcs of the same colors. The idea is the same: the three
arcs let you rotate the game object in the three axes, x, y, and z.
The white outer circle lets you rotate the game object based on the
view. Try it out and see.
You'll find the Inspector also lists out the rotation values of your game
object. This is in Euler angles. Same as before, you can type exact
values or drag the labels to edit them.
This will toggle between Global and Local. You can also do this by pressing X on your keyboard.
Snapping
You can make movement, rotation, or scaling done in precise increments by holding Ctrl while
moving/rotating/scaling.
2. Drag it to the other game object that will become the parent.
3. After that, the dragged game object is now parented to the other game
object.
Game Programming Using Unity 3D Lesson 1: Introduction To Unity. Page 13 of 17
Parented game objects follow the parent's position, rotation, and scale.
Exercise
Create a simple collection of game objects looking like the picture below. Make sure to parent all the
cylinders to the box.
Game Programming Using Unity 3D Lesson 1: Introduction To Unity. Page 14 of 17
Removing A Component
In contrast, see what happens when you remove the rigidbody that you previously added. To remove
the rigidbody, look at the Inspector view and locate the rigidbody component. You'll see a gear icon at
its upper-right hand corner.
Game Programming Using Unity 3D Lesson 1: Introduction To Unity. Page 15 of 17
Click on it and select “Remove Component” from the menu that appears.
Now start your game. You'll see that instead of falling, the cylinder remains floating in the air. Since
the rigidbody is not present, the cylinder isn't reacting like a real-world physical object anymore.
If you add a rigidbody once more, you'll find your game object has both a rigidbody and a light
component. Your game object would fall on the ground and shine a light at the same time.
This is the advantage of the component-based design that Unity makes use of. You can give any
game object any combination of components you want.
Game Programming Using Unity 3D Lesson 1: Introduction To Unity. Page 16 of 17
This is because you can only add one Light component to each game object at most. This holds true
for most component types. Like what the error message says, you can't add the same component
to a single game object multiple times.
So how do we fix this? What we do is we create an invisible game object that will hold the
second light, and parent that invisible game object to the cylinder. Your cylinder can have as
many children game objects as you want it to.
In Unity, you can create invisible game objects by going to GameObject > Create Empty. You can also
press Ctrl + Shift + N.
Game Programming Using Unity 3D Lesson 1: Introduction To Unity. Page 17 of 17
In Conclusion...
If you've come this far, congratulations! You're on your way in creating your own games with Unity.
You learned the basic gist of what Unity is, how to open a project, what game objects are all about
and how to move them around. You've learned what components are: the things that describe what a
game object is and how they behave.
In the next lesson, you'll learn more components that you can use, like terrain, basic visual effects like
particle effects and lens flares, and even music.
You'll be asked to create your own level and compile your application into an .exe file. You'll also learn
how to deploy your game to a web browser!