var jumpVector = new Vector2(0, jumpSpeed * jumpDirection * Time.deltaTime);
if (Input.GetKey(KeyCode.Space) && onGround)
{
characterRigidbody.AddForce(new Vector2(0, jumpForce * jumpDirection));
while (!onGround)
{
characterRigidbody.velocity = jumpVector;
}
jumpDirection *= -1;
characterRigidbody.gravityScale *= -1;
}