void ShootBullet(Vector3 to, bool onTarget, Transform hitTransform) { if (bulletsLeft > 0) { //deduct one bullet from magazine bulletsLeft--; ammoCounterText.text = bulletsLeft.ToString(); //See if it is Shotgun if (game.currentWeap.isShotgun) { for (int i = 0; i < game.currentWeap.shotgunBulletsPerShot; i++) { BulletScript bullet = Instantiate(bulletPrefab, transform.position + Vector3.up * 0.5f, Quaternion.identity).GetComponent <BulletScript>(); bullet.transform.LookAt(new Vector3(to.x, 0.5f, to.z)); bullet.transform.Rotate(Vector3.up * game.currentWeap.bulletSpreadDegrees * (game.currentWeap.shotgunBulletsPerShot / 2f - i)); bullet.myChart = game.currentWeap.chart; bulletList.AddFirst(bullet); } } else { //Spawn Bullet BulletScript bullet = Instantiate(bulletPrefab, transform.position + Vector3.up * 0.5f, Quaternion.identity).GetComponent <BulletScript>(); bullet.transform.LookAt(new Vector3(to.x, 0.5f, to.z)); bullet.myChart = game.currentWeap.chart; if (onTarget) { bullet.DrawDirectTrace(hitTransform); } bulletList.AddFirst(bullet); } PlayShootAudio(); game.RefreshWeaponDisplay(); } }