I already know how to rotate the player based on the mouse position, there are tons of tutorials about that. However, every time I need the camera to move (normally using cinemachine) I get a supper jittery movement and the way the player faces the mouse changes. This is the code I used as for now, yet this is a problem I've had for a long time and can't seem to find anyone asking about it.
I'm using the new Input system, though if needed I can use the old one and using the 2D camera in cinemachine
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
if(angle != 0)
{
savedAngle = angle;
}
transform.rotation = Quaternion.Euler(0, 0, savedAngle);