I have a boss with machine gun and i am trying to make him shoot for 5 seconds and then stop for 5 seconds and so on. I tried to create an IEnumerator and call it on Start (as far as i know i can not call it from update) but its not the behaviour i want as i always want him to start shooting when he spots the player. Any help is appreciated.
IEnumerator MachineGunShootTimer()
{
while(true)
{
machineGunOnCooldown = false;
yield return new WaitForSeconds(3f);
machineGunOnCooldown = true;
yield return new WaitForSeconds(3f);
}
}