2D gun aiming problem

Hi, I’m working on a 2d game where the player holds a weapon and aim /flip with the cursor.

When the player is flipped, the rotation / aiming with the mouse isn’t fluid anymore, the player is not able to do a full range of rotation.

Can someone help me with that ? See script below

[191737-weaponcontroller.txt|191737]

Code Snippet

            if (_orientation.x < 0 && _orientation.y < transform.localPosition.y)
                _direction = (_camera.ScreenToWorldPoint(temp) - transform.position).normalized;
            else
                _direction = (_camera.ScreenToWorldPoint(temp) - transform.position + _recoilOffsetLerped).normalized;
    

            _direction.x = _orientation.x;
            _direction.y = _orientation.x;*/
            
            float tempAngle = Mathf.Atan2(_direction.y, _direction.x) * Mathf.Rad2Deg;
    
            if (_orientation.x < 0)
            {
                GameState._isCharacterFlipped = true;
                _parent.transform.localScale = new Vector3(-1, 1, 1);
                if (_shootFX != null)
                {
                _shootFXTransform.localEulerAngles = new Vector3(0, 180, 0);
    
                }
                if (_orientation.y < transform.localPosition.y)
                    transform.eulerAngles = new Vector3(0, 0, (Mathf.Clamp(tempAngle, -180, -180 + _aimAngleRange / 2)) - 180);
                else
                    transform.eulerAngles = new Vector3(0, 0, Mathf.Clamp(tempAngle, 180 - _aimAngleRange / 2, 180) - 180 );
            }
            else
            {
    
                GameState._isCharacterFlipped = false;
    
                if (_shootFX != null)
                    _shootFXTransform.localEulerAngles = new Vector3(0, 0, 0);
                _parent.transform.localScale = new Vector3(1, 1, 1);
                transform.eulerAngles = new Vector3(0, 0, Mathf.Clamp(tempAngle, -_aimAngleRange / 2, _aimAngleRange / 2));
            }
    
            if (Input.GetKey(KeyCode.Mouse1) || Input.GetAxis("Aim") == 1.0f )
            {
                if (_magazineCapacity > 0)
                    _canShoot = true;
    
                if (_pointLightStruct.Length > 0)
                {
                    for (int i = 0; i < _pointLightStruct.Length; i++)
                    {
                        _toAdd = (_pointLightStruct<em>._maxLightAngle - _pointLightStruct<em>._minLightAngle) * Time.deltaTime* _aimingSpeed;</em></em>

_pointLightStruct._light.pointLightInnerAngle = Mathf.Clamp(_pointLightStruct._light.pointLightInnerAngle -= _toAdd, _pointLightStruct._minLightAngle, _pointLightStruct*._maxLightAngle);*

IEnumerator ShootWithSpread(float spreadAngle, int numberOfPellets, Quaternion transformRotation, Vector3 spawnerPosition, float powerMulti = 1f, float duration = 1f)
{
if(_shootFX!=null)
{
_shootFX.Play();
Recoil();

}
for (int i = 0; i < numberOfPellets; i++)
{
GameObject pellet = Instantiate(_projectile, spawnerPosition, transformRotation);
if(GameState._isCharacterFlipped)
pellet.transform.rotation = Quaternion.Euler(new Vector3(0, 0, transformRotation.eulerAngles.z + Random.Range(-spreadAngle, spreadAngle)+180));
else
pellet.transform.rotation = Quaternion.Euler(new Vector3(0, 0, transformRotation.eulerAngles.z + Random.Range(-spreadAngle, spreadAngle)));
pellet.GetComponent().AddForce(pellet.transform.right * firePower * powerMulti);
Destroy(pellet, duration);
yield return new WaitForSeconds(.01f);_

}