- Home /
3, 2, 1, GO! and GO dont "go", does not disappear
Quick one : How do I make "Go!" text disappear? Here's my code: void Update() { countdownText.text = ("Get Ready \r\n" + timeLeft);
if (timeLeft <= 0)
{
StopCoroutine("LoseTime");
countdownText.text = "GO!";
// something missing to text "GO!" disappear after 2 seconds
}
Answer by NoBrainer-David · Oct 11, 2017 at 01:20 PM
I see you already achieved what you wanted, but I want to present you with an alternative that I find a little more elegant. I suggest using the MonoBehavior.Invoke method.
Add this method to your MonoBehavior:
void SetEmptyText()
{
countdownText.text = "";
}
Then, when the time is run down, use this line:
Invoke("SetEmptyText", 2.0f);
Answer by Yuvii · Oct 11, 2017 at 12:27 PM
float timeWhenGo;
bool GoStarted = false;
bool TextReset = false;
void Update()
{
countdownText.text = ("Get Ready \r\n" + timeLeft);
if (!TextReset && timeLeft <= 0)
{
StopCoroutine("LoseTime");
countdownText.text = "GO!";
if(!GoStarted)
{
GoStarted = true;
timeWhenGo = Time.time;
}
if(Time.time >= timeWhenGo + 2)
{
TextReset = true;
countdownText.text = "";
}
}
this may be a bit dirty but it works :) let me know if you want me to explain.
Thank You @Yuvii ; I fixed it by adding one more if statement:
void Update() { countdownText.text = ("Get Ready \r\n" + timeLeft);
if (timeLeft <= 0)
{
StopCoroutine("LoseTime");
countdownText.text = "GO!";
}
if(timeLeft < 0)
{
countdownText.text = "";
}
}
Cheers!
hmm this looks weird, but if it works then it's all good :)
Your answer
Follow this Question
Related Questions
What project to do as I'm beginner and I want to learn all this stuff? 1 Answer
Help with opening 0 Answers
Clone of Jetpack Joyride 3 Answers
How do i change my ships bullet starting point.??? 2 Answers
Unity gets stuck on start up, any fix? 0 Answers