Hello guys and gals,
the general idea is to create a slider which operates like health bar which decreases constantly over time so that the game is timebound and over after 5ish minutes. So far I have tried to set a countdown for the slider and entered the value of the total time to run down to zero like this:
public class Countdown : MonoBehaviour
{
public float timeLeft = 32100.0f;
public bool stop = true;
private float minutes;
private float seconds;
public void startTimer(float from)
{
stop = false;
timeLeft = from;
Update();
}
void Update()
{
if (stop) return;
timeLeft -= Time.deltaTime;
minutes = Mathf.Floor(timeLeft / 60);
seconds = timeLeft % 60;
if (seconds > 59) seconds = 59;
if (minutes < 0)
{
stop = true;
minutes = 0;
seconds = 0;
}
// fraction = (timeLeft * 100) % 100;
}
}
A very big thank you in advance