Question by 
               Namsis2627 · Apr 21, 2019 at 09:18 AM · 
                animation2d game2d animationtimer countdown  
              
 
              Display cooldown timer
I'm new to unity, so I want to display a cooldown timer every time the player shoots, I made an animation as the cooldown icon but I'm not sure how I'm supposed to make it work with the code, that it stops when the time is up and plays again when the player shoots
This is the cooldown:
 public float firingRate = 1.8f;
 public float nextFire = 0.0f;
 
 
 void Update()
     {
         
         if (Input.GetButtonDown("Fire1") && Time.time > nextFireCannon)
         {
             
             Shoot();
 
             nextFire = Time.time + firingRate;
 
         }
         
         
     }
               Comment
              
 
               
              Answer by ArminAhmadi · Apr 22, 2019 at 03:35 AM
     public float firingRate = 1.8f;
     public float timer = 0.0f;
 
     private void Update()
     {
         if (Input.GetButtonDown("Fire1") && timer <= 0)
         {
             Shoot();
             timer = firingRate;
         }
         if (timer > 0)
         {
             timer -= time.deltaTime;
         }
     }
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                