Basically, I need to make a countdown that corresponds with the wait time in between waves. Currently once a wave finished there is a wait time before the next one starts. I want to make a counter that is displayed so i can visually show the wait time. ex. “Next Wave in: 5…4…3…2…1”. The only variables i really have is the waveWaitTime and a variable i set to that waveWaitTime to then decrement as the timer.
function WaveTimer()
{
//On function Start() var m is set to waveWaitTime which is 5.
while(m > -1)
{
yield WaitForSeconds(1);
m--;
}
}
Problem is that when i call this function anywhere in the Update function it decrements m like a million times a second. I need to make it so m is decremented at the same time the game is yielding for the waveWaitTime.
still cant get it to work. I it keeps decrementing the timer by 1 every frame to it shoots into the negative almost instantaneously. I need to to decrement at the same rate the game is waiting to start the next wave. So if the game is waiting 5 seconds. I need the counter which is 5 to decrement every second at the same time the game is waiting.
Okay so i got it so it decrements correctly however there is now no actual wait before the wave starts. The timer runs correctly though. here is the code i have so far.
are somehow faulty. What I mean by faulty is that they are true when the should be false. And if that is not the case, you need to set one more condition ex. createWave : boolean. if true, then you can create wave and not before. Set it to true via the “CountDown()”. When your count hits 0, createWave = true. Your Update picks that up, and you create your wave and set createWave to false, so that it does not create another wave until you insruct it.
Kay so i figured out a rather rudimentary and rough way of doing the counter but it works. Sometimes there is a slight glitch where the counting speeds up but that may vary depending on the computer you are using.