title: How to fix Bullet Rotation in Unity? (2D)
body: <p>So i'm having issues with a script I have, what it does is basically rotate the player graphics depending on where the mouse is aiming at. This works fine and as intended but my issue is that when I want to shoot on the opposite direction, that being the Left direction, it shoots the player instead of where it's aiming at.</p>
  
  <p>I've decided to record a small video to show the problem.</p>
  
  <p><a href="https://streamable.com/02zqz" rel="nofollow noreferrer">https://streamable.com/02zqz</a></p>
  
  <p>Here's the code to both the rotation and weapon script.</p>
  
  <p><strong>Rotating</strong></p>
  
  <pre><code>public class Rotating : MonoBehaviour
  {
      public PlayerController player;
      public float x;
  
      public Vector3 flipArm;
  
      void Start()
      {
          x = transform.localScale.x;
          flipArm = transform.localScale;
          player = GetComponentInParent&lt;PlayerController&gt;();
  
      }
  
      void Update()
      {
          Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition ) - transform.position;
          difference.Normalize();
  
          float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
  
          transform.rotation = Quaternion.Euler(0f, 0f, rotZ + 0);
  
          if(difference.x &gt;= 0)
          {
              transform.rotation = Quaternion.Euler(0f, 0f, rotZ);
              player.armRight = true;
          }
          else
          {
              transform.rotation = Quaternion.Euler(0f, 0f, rotZ+180);
              player.armRight = false;
          }
      }
  }
  </code></pre>
  
  <p><strong>Weapon</strong></p>
  
  <pre><code>public class Weapon : MonoBehaviour
  {
      public float shootDelay = 0;
      public float damage = 1;
  
      public LayerMask whatToHit;
  
      public Transform firePoint;
  
      public GameObject bullet;
  
      // Start is called before the first frame update
      void Start()
      {
          firePoint = transform.Find("FirePoint");
      }
  
      // Update is called once per frame
      void Update()
      {
          shootDelay += Time.deltaTime;
          if(shootDelay &gt;= 0.1f)
          {
              if(Input.GetMouseButton(0))
              {
                  shootDelay = 0;
                  Shot();
              }
          }
      }
  
      public void Shot()
      {
          Vector2 mousepos = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
  
          Vector2 firepointpos = new Vector2(firePoint.position.x, firePoint.position.y);
  
          Instantiate(bullet, firepointpos, transform.rotation);
  
          Debug.DrawLine(firepointpos, (mousepos - firepointpos) * 100, Color.cyan);
      }
  }
  </code></pre>