Game Development Reference
In-Depth Information
f_inAirTime = Time.time - f_inAirStartTime;
}
// Calculate actual motion
var v3_movement : Vector3 = (v3_moveDirection * f_moveSpeed)
+ Vector3 (0, f_verticalSpeed, 0); // Apply the vertical speed if
character fall down
v3_movement *= Time.deltaTime;
//Set the prepare animation to false
b_isPrepare = false;
////////////////////////////////////////////////////////
//Checking if the character is moving or not
if (v3_moveDirection != Vector3.zero) {
if (f_moveSpeed == walkSpeed) {
_animation.CrossFade(walkAnimation.name);
} else {
_animation.CrossFade(runAnimation.name);
}
} else {
_animation.CrossFade(idleAnimation.name);
}
// Move the controller
c_collisionFlags = controller.Move(v3_movement);
//Update rotation of the character
if ((v3_moveDirection != Vector3.zero) && (!b_isAiming)) {
transform.rotation = Quaternion.LookRotation(v3_
moveDirection);
}
12. Now we are done with the no aiming part. We will coninue to add the script to
check for the aiming part, which is similar to what we did in Project 5 , Creaing a
Rocket Launcher . So, let's add the script as follows:
} else {//Aiming
v3_moveDirection = Vector3.MoveTowards(v3_moveDirection,
v3_rocketDirection, 0.1);
v3_moveDirection = v3_moveDirection.normalized;
// Apply gravity
if (IsGrounded()) {
f_verticalSpeed = 0.0; //if our character is grounded
b_isJumping = false; //Checking if our character is in the
air or not
 
Search WWH ::




Custom Search