Unity 3D: Delay for 5 Seconds Using a Coroutine

9/28/2020 1:02:35 PM

In Unity 3D, delay the running of a function for a certain number of seconds.

using System.Collections;
using UnityEngine;

...

void Some_Function()
{
	StartCoroutine(Delay_Before_Next_Step(1));
}


IEnumerator Delay_Before_Next_Step(float delay_in_seconds)
{           
	//yield for X seconds.
	yield return new WaitForSeconds(delay_in_seconds);

	//do something
}