How to control how far a character can jump
Okay so i have a character that can jump to the height I want. The only problem is that the player can jump pretty far and appear to float pretty fast. It comes to the point where they walk on the ground the same speed as when they are jumping in the air. I have a jumpheight set for 8 (again I am okay with this height) and movespeed set for 5. That is okay for when he is on the ground but would I have to create a jumpspeed or something with a lesser value? Ive messed around with the angular drag, linear drag, mass and gravity. They either dont do anything or just change his jump height.
I know im probably making this sound confusing but I just think the player can move around too easily in the air and they seem to float for a while. I think itll make the game too easy. Its basically like they are on the moon except they can dart the player around just as fast as if they were on the ground. I would rather the player not have as mush of a movespeed when in the air so that the player would have to time their jumps a bit more carefully to win. Any help would be greatly appreciated!
void Start() { rb = GetComponent();
}
void Update()
{
if (Input.GetKey(KeyCode.LeftArrow))
{
rb.velocity = new Vector2(-movespeed, rb.velocity.y);
}
if (Input.GetKey(KeyCode.RightArrow))
{
rb.velocity = new Vector2(movespeed, rb.velocity.y);
}
if (moveright)
{
rb.velocity = new Vector2(movespeed, rb.velocity.y);
}
if (moveleft)
{
rb.velocity = new Vector2(-movespeed, rb.velocity.y);
}
if (Input.GetKey(KeyCode.Space)&&onGround==true)
{
rb.velocity = new Vector2(rb.velocity.x, jumpheight);
}
if (jump)
{
rb.velocity = new Vector2(rb.velocity.x, jumpheight);
jump = false;
}
}
void FixedUpdate()
{
onGround = Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround);
}
}