I'm building a game as my final project of university after some short research on internet I've used something like Waitforsecond() in unity but it didn't work, anyone know the solution, plesase help!
Asked
Active
Viewed 61 times
-4
-
3Where did you look with your short research? Did you check out the [Unity3D Forums](http://forum.unity3d.com/) and [Q&A site](http://answers.unity3d.com/)? Did you check out the [Unity Docs on Coroutines](http://docs.unity3d.com/ScriptReference/Coroutine.html)? Do you have any code to show? – PJvG May 06 '15 at 16:40
2 Answers
2
You can use coroutines for this:
void CallCoroutine()
{
StartCoroutine(PauseandGo(5));
}
IEnumerator PauseandGo(int seconds)
{
yield return new WaitForSeconds(seconds);
doSomething();
}

joreldraw
- 1,736
- 1
- 14
- 28
1
For this kind of stuff (call a method after X seconds without arguments), MonoBehaviour.Invoke is simpler to use and more readable than using coroutines.
Invoke("doSomething", 5);
will call doSomething() after 5 seconds

RSez
- 271
- 2
- 10