im making a 2½ game and im trying prevent the users from spam clicking the shoot key by adding a timer the way i try to do this is by having a bool that is set to true when the key is pressed down and then having an if statement in the update that checks if that bool is = true but for some odd reason it dosent work and i have no idea why any help is much appreciated this is my code
public float ShotDelay = 0.5f;
public float ShotDelayCounter;
public bool ShotBool;
// Use this for initialization
void Start ()
{
ShotBool = false;
ShotDelayCounter = ShotDelay;
}
// Update is called once per frame
void Update ()
{
if (Input.GetKey(KeyCode.x))
{
ShotBool = true;
}
if (ShotBool)
{
ShotDelayCounter -= Time.deltaTime;
}
}