I’ve used both InvokeRepeating and Co-routines in the past, but you can also handle the fire rate behavior quite simply with a timer variable. I find this much easier to understand and implement.
Inside my Enemy class, I have the following FixedUpdate() function. The Attack() function instantiates and fires the projectile, while the LookForPlayer() function handles the movement towards player based on the moveRadius and attackRadius, also toggles the isAttacking bool.
So far this seems to work just fine.
public void FixedUpdate()
{
LookForPlayer();
if (isAttacking)
{
attackTimer += Time.deltaTime;
if (attackTimer >= attackRate)
{
Attack();
attackTimer = 0.0f;
}
}
}