void Jumping() { if (keyboardControls) { if (Input.GetKeyDown(jumpKey)) { jumpIsPressed = true; if (raycastCollisionChecks.OnGround()) { ySpeed = 0; ySpeed += maxJumpVelocity; if (!disableJumping) { audioclip.clip = jump; audioclip.Play(); } } else if (raycastCollisionChecks.CollidingLeftOrRight() && !disableWallStuff) { ySpeed += wallJumpYVelocity; xSpeed += wallJumpXVelocity * -direction; audioclip.clip = jump; audioclip.Play(); //rigidbody2d.velocity.x += wallJumpXVelocity * direction; } } if (Input.GetKeyUp(jumpKey)) { jumpIsPressed = false; } if (!jumpIsPressed) { if (rigidbody2d.velocity.y > minJumpVelocity) { ySpeed = minJumpVelocity; } } } else { if (playerInput.WasButtonPressed(jumpButton)) { jumpIsPressed = true; if (raycastCollisionChecks.OnGround()) { ySpeed = 0; ySpeed += maxJumpVelocity; if (!disableJumping) { audioclip.clip = jump; audioclip.Play(); } } else if (raycastCollisionChecks.CollidingLeftOrRight() && !disableWallStuff) { ySpeed += wallJumpYVelocity; xSpeed += wallJumpXVelocity * -direction; audioclip.clip = jump; audioclip.Play(); //rigidbody2d.velocity.x += wallJumpXVelocity * direction; } } if (playerInput.WasButtonReleased(jumpButton)) { jumpIsPressed = false; } if (!jumpIsPressed) { if (rigidbody2d.velocity.y > minJumpVelocity) { ySpeed = minJumpVelocity; } } } //We apply gravity ourselves, going past Unitys RB gravity if (!raycastCollisionChecks.OnGround()) { ySpeed -= gravity * Time.deltaTime; } if (raycastCollisionChecks.CollidingLeftOrRight() && !disableWallStuff) { if (ySpeed < 0.0f) { ySpeed = -slideDownSpeed; } } if (!disableJumping) { rigidbody2d.velocity = new Vector2(xSpeed /*rigidbody2d.velocity.x*/, ySpeed); } }