In-Class
Exercise: Verify you can work with Unity
Step 1 (15 minutes): Editor Camera and the MainCamera
- create a new project
- manipulate the MainCamera
- Set to look at (10, 10,
-10) //
typically do not change the Z!
- Set the size of camera to
10
- manipulate the Editor
camera
- Zoom out your editor
camera so that you can see the entire bound of the MainCamera
- Hint: try
the following
- Zoom: On PC, middle
mouse scroll
- Pan: Click on empty
space in the editor Camera,
- Type Q to activate
the Hand tool
- Left-Mouse-Button
(LMB): click and drag
- Select the MainCamera in the Hierarchy window, and type F
to focus on the currently selected object
- Now, Center
your editor camera at the MainCamera so you can
see all the 4 bounds
Step 2 (15 minutes): GameObjects
- create and set game
objects
- Create 4 new games
objects: Brain, GreenUp, Plane, Egg
- Brain: size 3x3, locate
at (5,15, 0)
- GreenUp:
size 2x2, locate at (15, 15, 0)
- Plane: size 1.6x1.9,
locate at (5, 5, 0)
- Egg: size 1.1x1.4 locate
at (15, 5, 0)
- Verify: all 4 game
objects are within the bounds of your camera
- In the Editor Window,
- Select the Brain and
drag it out to (-10, 15, 0)
- Hint:
Type the W key to activate the Move tool
- Scale the Brain down to
1.5x15
- Hint:
Type the R key to activate the Scale tool
- Rotate the Brain by
45-degrees
- Hint:
Type the E key to activate the Rotate tool
- Now, use the combination
of WER keys to set the Brain back to 3x3, and located at (-15, 15,
0), with no rotation.
Step 3 (10 minutes): Camera Manipulation
- Now, focus your Editor
camera to center on Brain
- Hint:
Select the Brain, and then type F key to center on currently
selected object
- Now, pan your Editor camera
to center on the Arrow
- Hint: Type Q
key to select the Hand tool, and use a combination of LMB drag x/y
and middle mouse button
- Now, set your Editor
camera so that you can see all four objects again
Step 4 (15 minutes): Scripting and Object Behavior
- create a script and
program simple logic
- Create a script, name it:
LeftRightMove, for the plane to move it
- Hint:
Select the Plane, in the Inspector Window: Add Component: New Script
- Edit the LeftRightMove.cs script to move the GameObject:
- Define a variable that
is accessible via the Inspector Window
- Speed: 0.5 units per second (make sure to declare
this as public)
- Hint: Speed
* Time.smoothDeltaTime;
- Move towards the right,
if position.X>15, set position.X
to -15
- run your game to observe
the plane moving.
- Now, adjust the Speed
variable while the game is running to observe the Plane moving at
different speed.
- If you cannot see Speed
variable in the editor: make sure to the variable is declared as Public
- Now, quit the game to see
that your changes to the speed are not saved!!
- associate an existing
script with different exiting objects
- Associate the LeftRightMove script with the Egg and GreenUp
- Now, run to observe the
Egg and GreenUp moving in sync with the Plane
- Notice, when you quit,
all three objects are returned to their original position
- Once again, changes
during game play are not saved!!
- remove a component from a
GameObject
- Remove the LeftRightMove script from the Egg
- Now, run to observe the
Egg is not moving with the Plane/GreenUp
For
reference: this is what my project looks like at
the end of the above exercise.