Rotating weapon in 2d game

Hi, im making game mechanically similar to nuclear throne. I have player with weapon that sticks to his centre and Iwant that weapon to rotate around by player, but at some distance from him. This is code of my weapon

    void LateUpdate () {
       
        this.transform.position = new Vector3 (player.transform.position.x, player.transform.position.y, -1);

        Vector2 dir = Input.mousePosition - Camera.main.WorldToScreenPoint (transform.position);
        float angle = Mathf.Atan2 (dir.y, dir.x) * Mathf.Rad2Deg;
        transform.rotation = Quaternion.AngleAxis (angle, Vector3.forward);

}

I’m bad at english so i made drawing to help you understand me.
circle - player, red gun - weapon, green point - the center of sprite, the red circle is how weapon rotates. I want something like the right picture. There is code that

3129610--237051--unity xD.png

I’m not sure if it can help you, but maybe you can just create an empty wich you will rotate with your code and just manage the distance between the parent (the empty) and the child (your gun sprite).

Make the gun a child of your player. Fix the distance of the gun from the player. Now when your player moves the gun will also move.

Just addthi code snippet to your gun

public float speed = 10f;
void Update()
    {
        // Rotate the object around its local X axis at 1 degree per second
        transform.Rotate(Vector3.front *  speed* Time.deltaTime);

    }

If the player changes direction it will not work. But you can work out a solution using a boolean for direction.