time between monster attack

How I can put time into my trigger function because my life is lowering too fast.

void OnTriggerStay(Collider other)
    {
        if (other.gameObject.name == "player")
        {           
            if (GetComponent<Animation> ().Play ("attack02")) {
                StartCoroutine (attack());       
            }
        }

private IEnumerator attack(){
        guiDisplay.live -= 1;
        yield return new WaitForSeconds (2);
    }
}

You need a counter

Trigger:
if canAttack and counter <= 0 then counter = 1.0; Attack endif

Update:
if
    counter > 0 counter -= deltaTime
else
    counter = 0
endif
1 Like

Thanks