public void Shoot() { if (Time.time > nextShotTime) { nextShotTime = Time.time + fileRate / 1000; // From ms to s for (int i = 0; i < projectileSpawns.Count; i++) { if (projectileSpawns[i]) { // Spawn the projectile GameObject newPro = Instantiate(projectile, projectileSpawns[i].transform.position, projectileSpawns[i].transform.rotation) as GameObject; // Adds jitter on X and Y axis //newPro.transform.Rotate(Random.Range(-jitterY, jitterY), Random.Range(-jitterX, jitterX), 0); newPro.GetComponent <BaseProjectile>().FireProjectile(projectileSpawns[i], _target, damage, muzzleVeclocity); // Instantiate the muzzle effect Instantiate(VFX_Muzzle, projectileSpawns[i].transform.position, projectileSpawns[i].transform.rotation); } } if (projectileSpawns.Count > 0) { sfxAudio.PlayCustomSound(shootSoundIndex); } } }