how to wait for an n amount of seconds in unity code example
Example 1: wait for seconds unity
//In the example below the script will right "Hello" and 3 seconds later write "Goodbye" in the console
Start()
{
//Call the function Example()
StartCoroutine(Example());
}
Example()
{
Debug.Log("Hello");
//wait 3 seconds
yield return new WaitForSeconds(3);
Debug.Log("Goodbye");
}
Example 2: unity wait for seconds
void start() => StartCoroutine(MyIEnumerator());
IEnumerator MyIEnumerator()
{
Debug.Log("Hello world!");
yield return new WaitForSeconds(3);
Debug.Log("Goodbye world!");
}