Game Development Reference
In-Depth Information
var shootTarget : Transform;
// C# user:
public float heightSmoothTime = 0.1f;
public float distanceAimming = 1.5f;
public float distance = 2.5f;
public float height = 1.0f;
public Transform shootTarget;
7. Next, we will go to the Start() function to offset the target in the y position
and replace the old code with the following highlighted code:
// Unity JavaScript user:
function Start () {
var newCenter : Vector3 =
_targetTransform.collider.bounds.center + new
Vector3(0,0.45f,0);
_centerOffset = newCenter -
_targetTransform.position;
}
// C# user:
void Start () {
Vector3 newCenter =
_targetTransform.collider.bounds.center + new
Vector3(0,0.45f,0);
_centerOffset = newCenter -
_targetTransform.position;
}
8. Now, we will go to the LateUpdate() function because we want to make sure
that the camera's position will always be updated after our character has finished
moving. Add the following highlighted code to set up the camera's position when
our character is aiming:
Search WWH ::




Custom Search