void Update() { float x = Input.GetAxis("Horizontal"); float z = Input.GetAxis("Vertical"); if (x != 0f || z != 0f) { playerAnim.Move(); } else { playerAnim.Idle(); } Vector3 moveDirection = new Vector3(x, 0, z); moveDirection = cameraTransform.TransformDirection(moveDirection); moveDirection *= moveSpeed; if (characterController.isGrounded == true) { yVelocity = 0.0f; jumpCount = 0; if (jumped == true) { playerAnim.Grounded(); } jumped = false; } //Debug.Log(characterController.isGrounded); if (Input.GetButtonDown("Jump") && jumpCount < 2) { jumped = true; yVelocity = jumpSpeed; ++jumpCount; playerAnim.Jump(); } yVelocity += (gravity * Time.deltaTime); moveDirection.y = yVelocity; //Debug.Log(yVelocity); characterController.Move(moveDirection * Time.deltaTime); }