I have a basic 2d movement script, but the only problem is you can spam the space bar and fly, is it possible to stop this?
#pragma strict
var movespeed : float =6.0f;
var jumpspeed : float = 200f;
var gravity : float = 1f;
var jumpSpeed : float = 100f;
function Start () {
timer1 = 0;
}
function Update () {
if(Input.GetKey(KeyCode.A)){
transform.Translate(Vector3.left * movespeed * Time.deltaTime);
}
if(Input.GetKey(KeyCode.D)){
transform.Translate(Vector3.right * movespeed * Time.deltaTime);
}
if (Input.GetKeyDown(KeyCode.Space)) {
rigidbody.AddRelativeForce(0, jumpSpeed, 0);
timer1 = 10;
}
}
Sorry i didnt mean like that, i want some sort of timer to wait before you can jump again?
– Jackop222