Game Development Reference
In-Depth Information
12. After that, we need to add
CameraControl
to our
robot
. Let's go to the robot
Inspector
view and click on the
Add Component
button and then navigate to
Script
|
CameraControl
.
13. Then, we will see that our robot has
Character Controller
,
Character Control
(Script)
, and
Camera Control (Script)
attached to the
Inspector
view. Let's go
to the robot
Inspector
view again and set the
Character Controller
and
Camera
Control (Script)
parameters as follows:
Character Controller
Center
X
:
0
,
Y
:
-0.05
, and
Z
:
0
Height
2.4
Camera Control (Script)
Shoot Target
CameraAimingPosition
(drag it here)
We have now finished this step. Let's click on play to see the result. We will see
that we can press the Space bar to jump,
WASD
or arrow keys to walk, and if we
are pressing the
Shift
key while the character is walking, this will trigger the
run-
ning
state. The last thing to note is, if we hold the
E
key, our character will pre-
pare to shoot, and if we press the left-mouse button, our character will shoot.