private void Jump(bool jump) { bool jumpCooldownOver = (Time.time - jumpTimeStamp) >= minJumpInterval; if (jumpCooldownOver && isGrounded && jump) { if (playerState == PlayerState.Exhaust) { jumpForce = 6f; } else { jumpForce = 12f; } heightBefore = this.transform.position.y; jumpTimeStamp = Time.time; rigidBody.AddForce(Vector3.up * jumpForce, ForceMode.Impulse); playerState = PlayerState.Jump; isJumping = true; } if (!wasGrounded && isGrounded) { float fallAmount = maximumHeight - this.transform.position.y; playerAgent.CheckOnLanding(fallAmount, heightBefore); if (fallAmount > 6.0f || hp < 0.0f) { hp = -100; playerState = PlayerState.Exhaust; if (!isRecovering) { Invoke("Recover", 10.0f); isRecovering = true; } } animator.SetTrigger("Land"); maximumHeight = this.transform.position.y; } if (!isGrounded && wasGrounded) { animator.SetTrigger("Jump"); if (isJumping) { playerState = PlayerState.Jump; } else { heightBefore = this.transform.position.y; playerState = PlayerState.Fall; } } }