Disable acceleration when in air

hi,
my problem is when my sphere jumps, it accelerates in the air without a reason.
my jump script is very basic, checks whether sphere is grounded and space is pressed:

if (Input.GetKeyDown(KeyCode.Space) && IsGrounded())
{
		rigidbody.velocity.y = jumpHeight;
}

I tried to set low velocity.x and sleep, but it didn’t help.

I saw your duplicate question: is the problem that the ball is able to jump, even while it’s in the air? If so, the problem is most likely with your IsGrounded function.

Don’t try and modify gameObject.velocity.y. Instead modify gameObject.velocity with a new Vector3 like this:

if (Input.GetKeyDown(KeyCode.Space) && IsGrounded()){        
     rigidbody.velocity = new Vector3(rigidbody.velocity.x, jumpVelocity, rigidbody.velocity.z);
}

here’s the answer:

rigidbody.drag = 20;

rigidbody.Drag