- Home /
This question was
closed Jul 05, 2018 at 10:37 AM by
acclogin71.
Question by
acclogin71 · Jul 04, 2018 at 04:36 PM ·
resettimer countdownracing game
racing game timer doesnt reset
so I made timer in racing game to count lap time. but it only stops after I complete 3 laps, when I press back and click on that level again, position of player resets to origin, but timer doesnt reset to zero. please help
Comment
Answer by tormentoarmagedoom · Jul 04, 2018 at 04:42 PM
Good day.
We can not help you without the script... Ypu only need to set it to 0 when a lap is completed...
it does set to 0 when lap is completed. but when I go back to main menu and come back to that level, timer remains on.
here's script for lap time counting
public class LapTime$$anonymous$$anager : $$anonymous$$onoBehaviour {
public static int $$anonymous$$inuteCount;
public static int SecondCount;
public static float $$anonymous$$illiCount;
public static string $$anonymous$$illiDisplay;
public GameObject $$anonymous$$inuteBox;
public GameObject SecondBox;
public GameObject $$anonymous$$illiBox;
// Update is called once per frame
void Update ()
{
$$anonymous$$illiCount += Time.deltaTime * 10;
$$anonymous$$illiDisplay = $$anonymous$$illiCount.ToString("F0");
$$anonymous$$illiBox.GetComponent<Text>().text = "" + $$anonymous$$illiDisplay;
if ($$anonymous$$illiCount >= 10)
{
$$anonymous$$illiCount = 0;
SecondCount += 1;
}
if (SecondCount <= 9)
{
SecondBox.GetComponent<Text>().text = "0" + SecondCount + ".";
}
else
{
SecondBox.GetComponent<Text>().text = "" + SecondCount + ".";
}
if (SecondCount >= 60)
{
SecondCount = 0;
$$anonymous$$inuteCount += 1;
}
if ($$anonymous$$inuteCount <= 9)
{
$$anonymous$$inuteBox.GetComponent<Text>().text = "0" + $$anonymous$$inuteCount + ":";
}
else
{
$$anonymous$$inuteBox.GetComponent<Text>().text = "" + $$anonymous$$inuteCount + ":";
}
}
}