unity startcoroutine every frame code example
Example: Unity how to put IEnumerator in update and loop once with yeild return new waitforseconds
private IEnumerator OnTriggerStay(Collider other)
{
if (other.tag == "Player" && !_isDamaging)
{
_isDamaging = true;
if (_playerHealth != null)
{
_playerHealth.Damage(10);
}
yield return new WaitForSeconds(1.5f);
_isDamaging = false;
}
}