Attack Animation

This is my code

 bugAnimator.SetBool("Attack", true);
                        attackDelay += Time.deltaTime;
    
                        float maxAttackDelay = 3f;
               
                       
    
                        if(attackDelay>= maxAttackDelay)
                        {
                            bugAnimator.SetTrigger("InitAttack");
                            gameMaster.TurretHealth -= Attack;
                            attackDelay -= maxAttackDelay;
                        }

It works very well but problem is that in moment that is health of player reduced(Turret Health) by enemy(bug) , enemy is beginning “swing” so some time is needed like offset before actually reducing health.
So how to run animation with some offset (does not matter if in script or animator controller)

You can do that with Coroutines:

float attackDelay = 3f;
float damageDelay = 1f;
bool canAttack = true;

public void AttackSequence ( ){
  bugAnimator.SetBool("Attack", true);
  if (canAttack )
    StartCouroutine( StartAttackDelay() );
}

IEnumerator StartAttackDelay() 
{
       canAttack = false;
        yield return new WaitForSeconds( attackDelay );
       bugAnimator.SetTrigger("InitAttack");
        StartCouroutine(DoDamageToTurret(Attack) );
} 

IEnumerator DoDamageToTurret(float damage) 
{
        yield return new WaitForSeconds( damageDelay );
        gameMaster.TurretHealth -= damage;
        canAttack = true;
}