how to wait a couple seconds before exectuting code in unity code example
Example 1: how to make a line of code wait unity
Start()
{
StartCoroutine(Example());
}
Example()
{
Debug.Log("Hello");
yield return new WaitForSeconds(3);
Debug.Log("Goodbye");
}
Example 2: wait for a second unity
void Start()
{
StartCoroutine(ExampleCoroutine());
}
IEnumerator ExampleCoroutine()
{
Debug.Log("Started Coroutine at timestamp : " + Time.time);
yield return new WaitForSeconds(5);
Debug.Log("Finished Coroutine at timestamp : " + Time.time);
}