How to disable flying?

my player is rigidbody , so i use this script ( c# ) for jumping . Problem is if someone press space 2 , 3, 4 ,5 times player start “flying”

Script:

Blockquote

public float jacinaSkoka = 1600;

if( Input.GetKeyDown(“space”))
{
rigidbody.AddForce(Vector3.up * jacinaSkoka);
}

Blockquote

i want , if someone press space 2, 3, 4 times in a given time interval, for example, 0.6 seconds, the player jumps only once

Hey m8 :slight_smile: Had same problem… Here is what i did

if ((Input.GetKeyDown(“space”) || Input.GetKeyDown(“up”) || Input.GetKeyDown(“w”)) && Physics.Raycast(transform.position, Vector3.down, 1.0f))
{
rigidbody.AddForce(Vector3.up * playerJumpSpeed, ForceMode.Impulse);
}