So I have been making a top-down shooter style game, and it has been going pretty well, other than the fact that when I change the value of “timeBetweenShots” (the fire rate variable) it doesn’t change the fire rate at all, no matter if I set it at 0.001, 0.1, 1, or even 100. It stays a constant line of bullets. I have tried changing around the script a bit, but nothing changes. Please look at my script, and tell me what is wrong if you can.
using UnityEngine;
using System.Collections;
public class GunFire : MonoBehaviour {
public bool isFiring;
public BulletScript bullet;
public float bulletSpeed;
public float timeBetweenShots;
private float shotCounter;
public Transform firePoint;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if(isFiring)
{
shotCounter -= Time.deltaTime;
if (shotCounter <= 0)
{
shotCounter = timeBetweenShots;
BulletScript newBullet = Instantiate (bullet, firePoint.position, firePoint.rotation) as BulletScript;
newBullet.speed = bulletSpeed;
}
else {
shotCounter = 0;
}
}
}
}