Question by 
               doobtvofi · Jul 24, 2020 at 11:07 AM · 
                timercountdowntimer countdowntimer-script  
              
 
              I need a "loop" timer that disables a action until the timer resets.
I am just starting so my code may be messy, sorry, but this is what I have so far:
  public int slowDownTimeLeft = 4;
 // Update is called once per frame
 void Update()
 {    
     if (Input.GetKeyDown("w"))
     {
        forwardSpeed = forwardSpeed/4;
        slowDownTimeLeft--; here I need it to repeat
     } if(Input.GetKeyUp("w"))
     {
         forwardSpeed = forwardSpeed * 4;
         slowDownTimeLeft++; and here also.
     }
     if(slowDownTimeLeft <= 0)
     {
         //this will be where the slowDownTimer will reset and the ability to slow down will be avaliable again.
     }
 
               I need so slowDownTimeLeft-- actually repeats, doesnt only get called once, so the timer resets and then the slow down ability becomes available again. and also that slowDownTimeLeft++ repeats after the "w" key gets released. Thank you :)
               Comment
              
 
               
              wait so can't you just set it back to 4 when it runs out? what's the problem exactly
Your answer