Question by 
               sharperthenever1977 · Jul 28, 2021 at 01:10 PM · 
                c#timetimer countdowntimer-script  
              
 
              Where and how should I stop the counter when the while loop is ended ?
At the top of the script :
 public string counter;
 
 float timer = 0.0f;
 bool count = true;
 private bool startSpeedUp = false;
 
               Then inside Update()
 private void Update()
     {
         if(Input.GetKeyDown(KeyCode.V))
         {
             startSpeedUp = true;
         }
 
         if(startSpeedUp)
         {
             SpeedUp();
 
             if (count)
             {
                 timer += Time.deltaTime;
                 int seconds = (int)timer % 60;
                 counter = seconds.ToString();
             }
         }
     }
 
               Then I tried to stop the counter inside the SpeedUp()
 private void SpeedUp()
     {
         if (timeElapsed < lerpDuration)
         {
             timeElapsed += Time.deltaTime;
             valueToLerp = Mathf.Lerp(endValue, startValue, timeElapsed / lerpDuration);
             animator.SetFloat("Forward", valueToLerp);
         }
 
         count = false;
     }
 
               But this is wrong it will make the counter stop before its starts.
I want to count the time in the SpeedUp in the while. When the while loop end stops the counter.
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
How to get a countdown timer with values entered by the player 0 Answers
Allow player to Press Input.GetKeyDown once per update ? 0 Answers
Is there a way to calculate elapsed Time in total? (Even when the App is closed etc.) 1 Answer
Clock doesn't stop when reaches 0.0. Can you help me with this. 1 Answer
Farming game Time management 0 Answers