jumping at a specific height (using rigid body)

I want my character to jump when I press the space bar but not to keep going up if I keep holding it. I want to use rigidbody but not character controller. Here is my code:

if (Input.GetKey("space")) {
     	animator.SetBool("Jumping", true );
     	animator.SetBool("Jumping", false );

PS I have tried GetKeyDown but then my character doesn’t go up at all.

Try GetKeyDown() again, but use:


This assumes you left your mass at 1.0.