You should only decrease totalTime if it is greater or equal than 0 by surrounding the code that is related to the decreasing of the timer in an if statement.
In addition, since totalTime is a float that can become negative in one decrement (without reaching 0), you should also check if it is less than 0, and set it to 0 if that is true.
I think this will work, because when working with health or something similar you do this.
So basically you say
if(time <= 0)
{
time = 0;
}
This makes it so that when ever time is less than zero, it will just become 0.
Note that there is no need to trigger the decrement code every tick if the time has already reached 0, so in addition to what you mentioned, the code that decrements the timer should only be triggered when timer is greater than 0.
Note that there is no need to trigger the decrement code every tick if the time has already reached 0, so in addition to what you mentioned, the code that decrements the timer should only be triggered when timer is greater than 0.
– davidmaamoaix