The script that I’ve been using to create projectiles suddenly stopped working as planned. It used to have a period of time in between shots around one second long that you couldn’t fire the weapon as you were reloading it.
//this is for the different spots the gun fires out of and the projectile I instantiate
public GameObject projectile;
public Transform firePoint;
public Transform firePoint2;
public Transform firePoint3;
public Transform firePoint4;
//the floats i use to determine how fast and frequently you can fire
private float fireRate = 3f;
private float nextFire = 5f;
void Update () {
if (Input.GetAxisRaw ("Fire2")>0 && Time.time > nextFire){
Instantiate (projectile, firePoint.position, Quaternion.Euler (0,0,0));
Instantiate (projectile, firePoint2.position, Quaternion.Euler (0,0,0));
Instantiate (projectile, firePoint3.position, Quaternion.Euler (0,0,0));
Instantiate (projectile, firePoint4.position, Quaternion.Euler (0, 0, 0));
nextFire = Time.time + fireRate;
}
it’s supposed to make the time to reload the current time plus my fire rate. that way Time.time has to be greater than itself plus firerate in order to fire. I do not know where I went wrong with this.