How to insert instantiate bullet frame rate

Hi guys

what’s the best way for insert a fire rate in my script?
Now for every frame it’s instantiate bullet.

if (fuoco==true)
{
var bullet = (GameObject)Instantiate(bulletprefab, bulletspawn.position, bulletspawn.rotation);
bullet.GetComponent().velocity = bullet.transform.forward * 20;
Destroy(bullet, 2.0f);
fire()
}

Thank you

I have done my fire with a coroutine which makes everything much easier, with the
yield return WaitForSeconds(time) you can easily decide how many shots per seconds you want to shoot.

If you think coroutines are stupid then you could save the time and check when the Time.fixedTime has exceeded limit… something as following

void Shoot()
{
float lastShotTime = 0;
while (shooting){

if(lastShotTime+fireRate < Time.fixedTime){
Instantiate bullet;
MoveInDirection();
lastShotTime = Time.fixedTime;
}
}



}