Game Development Reference
In-Depth Information
_isAiming = false;
}
C# user:
void Start () {
_inAirStartTime = Time.time;
_currentEulerAngle = transform.eulerAngles;
_isAiming = false;
}
4. Then, we go to the Update() function to set the running and aiming animation
controller. Let's go to the If (IsGround) function and replace the old code
from if (!_isJumping && (_motionState ==
MOTION_STATE.GROUND)) {…} to if (_moveDirection != Vect-
or3.zero) {…} , as shown in the following highlighted script:
// Unity JavaScript user:
If (IsGround) {
} else {
}
if (!_isJumping) {
_isAiming = (Input.GetKey(KeyCode.E));
if (_isAiming) {
_isShot = Input.GetButtonDown("Fire1");
} else {
if (_motionState == MOTION_STATE.GROUND) {
_isRun = (Input.GetKey (KeyCode.LeftShift) ||
Input.GetKey (KeyCode.RightShift));
if (_isRun) {
if (_moveDirection != Vector3.zero) {
_moveSpeed += 0.15f;
_moveSpeed =
Mathf.Clamp(_moveSpeed,0.0f,runSpeed);
}
Search WWH ::




Custom Search