Firing things really fast?!

So in my game, I have a bullet fire script. Here’s the part that controls the timing:

static var rate:int = 40;

//BulletShot function

function Update()
    {
        timer++;
    
        if(Input.GetMouseButton(0) && timer > rate)
        {
            BulletShot();
            timer = 0;
        }
    }

The problem is that when I run the exported game, and I have it at a low graphics setting, your fire rate is STUPIDLY fast. Is there any easy way I can fix this?

Well, if your rate is less than 1, it will fire every frame. Update runs every frame, so when 1 frame passes, timer increases by 1.

What you probably want to do is:

timer += Time.deltaTime;

This allows you to control the time between shots, not the frames between shots.

I hope this helps! :slight_smile: