private void Animate() { //Debug.Log("____"); bool isWalking = animator.GetBool(isWalkingHash); bool isJumping = animator.GetBool(isJumpingHash); bool isRunningBack = animator.GetBool(isRunningBackHash); bool isRunning = animator.GetBool(isRunningHash); bool isLeft = animator.GetBool(isLeftHash); bool isRight = animator.GetBool(isRightHash); bool isCrouched = animator.GetBool(isCrouchedHash); bool isClimbing = animator.GetBool(isClimbingHash); float x = Input.GetAxis("Horizontal"); float z = Input.GetAxis("Vertical"); //Debug.Log("Initial isCrouched:"+crouching); // Debug.Log(climbing + " XDDD " + Input.GetKeyDown(KeyCode.W)); if (climbing && (Input.GetButton("Ladder") || PoseParser.GETGestureAsString().CompareTo("L") == 0)) { animator.SetBool(isClimbingHash, true); } else { animator.SetBool(isClimbingHash, false); } if (!isWalking && (z > 0.02f || PoseParser.GETGestureAsString().CompareTo("F") == 0)) { if (Input.GetKey(KeyCode.LeftShift) || PoseParser.GETGestureAsString().CompareTo("F") == 0) { //Debug.Log("running"); animator.SetBool(isRunningHash, true); player.setSpeed(runningSpeed); } else if (!crouching) { //Debug.Log("walking"); animator.SetBool(isWalkingHash, true); player.setSpeed(walkingSpeed); } } if (!isRunningBack && z < -0.02f) { animator.SetBool(isRunningBackHash, true); } if (z <= 0.02f && z >= -0.02f && PoseParser.GETGestureAsString().CompareTo("F") != 0) { animator.SetBool(isWalkingHash, false); animator.SetBool(isRunningHash, false); animator.SetBool(isRunningBackHash, false); } if ((!isRight && x > 0.02f) || (!isRight && PoseParser.GETGestureAsString().CompareTo("I") == 0)) { animator.SetBool(isRightHash, true); } if (x <= 0.02f && x >= -0.02f && PoseParser.GETGestureAsString().CompareTo("I") != 0 && PoseParser.GETGestureAsString().CompareTo("O") != 0) { animator.SetBool(isLeftHash, false); animator.SetBool(isRightHash, false); } if ((!isLeft && x < -0.02f) || (!isLeft && PoseParser.GETGestureAsString().CompareTo("O") == 0)) { animator.SetBool(isLeftHash, true); } // if ((Input.GetKeyDown(KeyCode.LeftShift) || PoseParser.GETGestureAsString().CompareTo("F") == 0) && isCrouched) { // animator.SetBool(isCrouchedHash, false); // } if (Input.GetKeyDown(KeyCode.LeftShift) && (isWalking || z > 0.02f)) { animator.SetBool(isWalkingHash, false); animator.SetBool(isCrouchedHash, false); animator.SetBool(isRunningHash, true); player.setSpeed(runningSpeed); } else if (Input.GetKeyUp(KeyCode.LeftShift) && isRunning) { animator.SetBool(isWalkingHash, true); animator.SetBool(isRunningHash, false); player.setSpeed(walkingSpeed); } // } else if(PoseParser.GETGestureAsString().CompareTo("N")==0 && isRunning){ // animator.SetBool(isWalkingHash, false); // animator.SetBool(isRunningHash, false); // player.setSpeed(walkingSpeed); // } // if (Input.GetKeyDown(KeyCode.LeftControl) && !isCrouched && !isRunning) { // animator.SetBool(isCrouchedHash, true); // } else if (Input.GetKeyDown(KeyCode.LeftControl) && isCrouched) { // animator.SetBool(isCrouchedHash, false); // } if ((Input.GetButtonDown("Jump") || !isGrounded) && !climbing) { animator.SetBool(isJumpingHash, true); // animator.SetBool(isRunningHash, false); } else if (isGrounded) { animator.SetBool(isJumpingHash, false); } if ((Input.GetKeyDown(KeyCode.LeftControl) || PoseParser.GETGestureAsString().CompareTo("C") == 0) && !crouching && !isRunning) { crouching = true; animator.SetBool(isWalkingHash, false); animator.SetBool(isRunningHash, false); animator.SetBool(isCrouchedHash, true); } else if ((Input.GetKeyDown(KeyCode.LeftControl) || PoseParser.GETGestureAsString().CompareTo("N") == 0) && crouching) { crouching = false; // Debug.Log("uncrouch"); animator.SetBool(isCrouchedHash, false); animator.SetBool(isWalkingHash, false); animator.SetBool(isRunningHash, false); } if (z >= 0.02f && crouching) { animator.SetBool(isCrouchedHash, true); animator.SetBool(isWalkingHash, true); animator.SetBool(isRunningHash, false); } else if ((z <= 0.02f && z >= -0.02f) && crouching) { animator.SetBool(isCrouchedHash, true); animator.SetBool(isWalkingHash, false); animator.SetBool(isRunningHash, false); } }
private void Animate() { bool isWalking = animator.GetBool(isWalkingHash); bool isJumping = animator.GetBool(isJumpingHash); bool isRunningBack = animator.GetBool(isRunningBackHash); bool isRunning = animator.GetBool(isRunningHash); bool isLeft = animator.GetBool(isLeftHash); bool isRight = animator.GetBool(isRightHash); bool isCrouched = animator.GetBool(isCrouchedHash); bool isClimbing = animator.GetBool(isClimbingHash); float x = Input.GetAxis("Horizontal"); float z = Input.GetAxis("Vertical"); // Debug.Log(climbing + " XDDD " + Input.GetKeyDown(KeyCode.W)); Debug.Log(climbing); if (climbing && Input.GetKey(KeyCode.W)) { animator.SetBool(isClimbingHash, true); } else { animator.SetBool(isClimbingHash, false); } if (!isWalking && z > 0.02f) { if (Input.GetKey(KeyCode.LeftShift)) { animator.SetBool(isRunningHash, true); player.setSpeed(runningSpeed); } else { animator.SetBool(isWalkingHash, true); player.setSpeed(walkingSpeed); } } if (!isRunningBack && z < -0.02f) { animator.SetBool(isRunningBackHash, true); } if (z <= 0.02f && z >= -0.02f) { animator.SetBool(isWalkingHash, false); animator.SetBool(isRunningHash, false); animator.SetBool(isRunningBackHash, false); } if (!isRight && x > 0.02f) { animator.SetBool(isRightHash, true); } if (x <= 0.02f && x >= -0.02f) { animator.SetBool(isLeftHash, false); animator.SetBool(isRightHash, false); } if (!isLeft && x < -0.02f) { animator.SetBool(isLeftHash, true); } if (Input.GetKeyDown(KeyCode.LeftShift) && (isWalking || z > 0.02f)) { animator.SetBool(isWalkingHash, false); animator.SetBool(isRunningHash, true); player.setSpeed(runningSpeed); } else if (Input.GetKeyUp(KeyCode.LeftShift) && isRunning) { animator.SetBool(isWalkingHash, true); animator.SetBool(isRunningHash, false); player.setSpeed(walkingSpeed); } if (Input.GetButtonDown("Jump") || !isGrounded) { animator.SetBool(isJumpingHash, true); // animator.SetBool(isRunningHash, false); } else if (isGrounded) { animator.SetBool(isJumpingHash, false); } if (Input.GetKeyDown(KeyCode.LeftControl) && !isCrouched) { animator.SetBool(isCrouchedHash, true); } else if (Input.GetKeyUp(KeyCode.LeftControl) && isCrouched) { animator.SetBool(isCrouchedHash, false); } }