Game Development Reference
In-Depth Information
_characterControl.GetCharacterEulerAngle.y, 0);
_cameraTransform.position = targetCenter;
_cameraTransform.position += currentRotation *
Vector3.back * distanceAimming;
Vector3 newCameraPos = _cameraTransform.position;
newCameraPos.y += height;
_cameraTransform.position = newCameraPos;
_cameraTransform.LookAt(shootTarget.position);
}
}
9. Now, we've finished the first coding part. We need to go back to Unity and set up
our character and camera's target position when aiming. Let's go to the
Re-
sources/FBX/Robot Artwork
folder in the
Project
view and drag the
ro-
bot
prefab to the
Hierarchy
view; then go to the robot
Inspector
view and set it
as follows:
Transform
Position
X
:
0
,
Y
:
0.25
, and
Z
:
-6
Animator
Controller
MyAnimatorController
10. Next, we will create our
CameraAiming
position object by going to
GameOb-
ject
|
Create Empty
; name it
CameraAimingPosition
. Then, we need to
drag this inside our game object of
robot
, as shown in the following screenshot:
11. Then, we click on the
CameraAimingPosition
option and set
Transform
as fol-
lows:
Transform
Position
X
:
0.6
,
Y
:
1
, and
Z
:
0.4