+ 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?
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
+ 13
Thank you so much Erangađ, I think wait for seconds realtime or wait for seconds might be what I am looking for đ
+ 7
i need to wait in html
+ 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.