Vector3 cursorPosition = camera.ScreenToWorldPoint(Input.mousePosition);
Vector2 direction = (cursorPosition - transform.position).normalized;
transform.right = direction;
This would rotate the player to face in the direction of the mouse.
No need for anything else.
This is how I rotate the gun in our game.