//Fires a bullet towards the crosshair private void FireBullet() { //Start the weapon cooldown WeaponHot = true; Invoke("CoolWeapon", FiringCooldown); //Figure out which direction the bullet will be fired, and the position/rotation it should be spawned in with Vector3 ShootDirection = Vector3.Normalize(CursorLocation.Instance.Get() - transform.position); float ShootAngle = Vector3.Angle(ShootDirection, transform.right); Quaternion BulletRotation = Quaternion.Euler(0f, 0f, ShootDirection.y > 0f ? ShootAngle : -ShootAngle); Vector3 BulletPosition = WeaponAiming.WeaponFlipped ? FlippedBulletSpawn.transform.position : NormalBulletSpawn.transform.position; //Spawn a new bullet in with these values GameObject BulletSpawn = Instantiate(BulletPrefab, BulletPosition, BulletRotation); BulletSpawn.GetComponent <BulletTravel>().InitializeBullet(ShootDirection); //Display the muzzle flash effect MuzzleFlash.TriggerMuzzleFlash(); }