unity how to make code wait code example
Example 1: how to make a method wait in unity
public float timeLeft = 30.0f
void Update()
{
timeLeft -= Time.deltaTime;
if (timeLeft < 0)
{
//Do your method here
}
}
Example 2: wait time in unity
using System.Collections;
private void Start()
{
StartCoroutine(Wait());
}
IEnumerator Wait()
{
//To wait, type this:
//Stuff before waiting
yield return new WaitForSeconds(/*number of seconds*/);
//Stuff after waiting.
}