unity add a delay in update function
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OverTime : MonoBehaviour
{
private bool Timed;
// Start is called before the first frame update
void Start()
{
StartCoroutine(CountDown(5));
}
// Update is called once per frame
void Update()
{
if(!Timed)
{
StartCoroutine(CountDown(5));
}
}
IEnumerator CountDown(float RestartAfter)
{
Timed = true;
yield return new WaitForSeconds(RestartAfter);
print(Time.time);
Timed = false;
}
}