+ 13

Is there a "setTimeOut" similar function for C# with Unity? If not ,how can I do something like that?

I want my game to reset after a couple of seconds when the player dies so I can have a "die" animation, how can I do this? Could you help me?

29th Mar 2017, 2:45 PM
C.E.
C.E. - avatar
4 Answers
+ 2
in C#u can use Timers https://msdn.microsoft.com/en-us/library/system.timers.timer(v=vs.110).aspx or Threads https://msdn.microsoft.com/en-us/library/aa645740(v=vs.71).aspx is this wht u looking for in Unity - WaitForSeconds https://docs.unity3d.com/ScriptReference/WaitForSeconds.html
29th Mar 2017, 3:11 PM
Eranga
Eranga - avatar
+ 13
Thank you so much Eranga😄, I think wait for seconds realtime or wait for seconds might be what I am looking for 😉
29th Mar 2017, 7:05 PM
C.E.
C.E. - avatar
+ 7
i need to wait in html
29th Mar 2017, 5:42 PM
Theprogrammers
Theprogrammers - avatar
+ 4
A coroutine is perfect for wait times It's basically a thread. It has a Einumerator return type. Heres how to use it. using System.Collections; //import needed float waitTime = 4f; // time to wait bool dieing; void Dead(){ if(!dieing) startCoroutine(dieing(4f)); } Einumerator dieing(float waitTime){ dieing = true; yield return new waitForSeconds(waitTime); //dieing animation here dieing = !dieing; } note* I apologise if i spelt something wrong, am on phone.
31st Mar 2017, 3:33 PM
Rrestoring faith
Rrestoring faith - avatar