public void JumpControl() { if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) { if (grounded) { myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpForce); stoppedJumping = false; jumpSound.Play(); } if (!grounded && doubleJump) { myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpForce); jumpTimeCounter = jumpTime; doubleJump = false; stoppedJumping = false; jumpSound.Play(); } } if ((Input.GetKey(KeyCode.Space) || Input.GetMouseButton(0)) && !stoppedJumping) { if (jumpTimeCounter > 0) { myRigidbody.velocity = new Vector2(myRigidbody.velocity.x, jumpForce); jumpTimeCounter -= Time.deltaTime; } } if (Input.GetKeyUp(KeyCode.Space) || Input.GetMouseButtonUp(0)) { jumpTimeCounter = 0; stoppedJumping = true; } if (grounded) { jumpTimeCounter = jumpTime; doubleJump = true; } myAnimator.SetFloat("Speed", myRigidbody.velocity.x); myAnimator.SetBool("Grounded", grounded); myAnimator.SetBool("SafeMode", thePowerupManager.GetSafeMode()); myAnimator.SetBool("FlyingMode", thePowerupManager.GetFlyingMode()); }