- Home /
Question by
Vyse629 · Nov 22, 2016 at 09:06 AM ·
timerinvokestartcoroutine
Can't get timer to count correct
I have it so after about 3 seconds it should then go on with the code to produce the "HI" message. the problem is that it doesn't even show the "Good Job etc..." message and goes straight to "HI"
script.jpg
(75.1 kB)
Comment
Answer by Mister-Mortal · Nov 22, 2016 at 07:00 PM
You are using coroutine in a wrong manner. Calling coroutine doesn't stop execution of the main thread. Here's a good explanation how coroutines work.
To achieve your desired effect remove text assignments from your GetToBridge() method and put them inside coroutine, like this:
IEnumerator TimerInvoke(float time)
{
briefMessage.text = "Good Job now...";
yield return new WaitForSeconds(time);
briefMessage.text = "HI";
}
Awesome thank you that helped a lot. and also found another problem right after it was destroying the object holding the script to soon to put up the "HI" thanks
Your answer
