Free camera look question

I am making a space game where I want the player to be able to navigate a 3d map of all the stars. For this I made a simple script that translates the mouse X and Y axis into a change in localEulerAngles. It works perfectly, however when you move the mosue upwards and “flip” upside down, the movement is inverted. This makes total scense of course, but I don;t know how to fix it.

Here is my code

xRot += Input.GetAxis("Mouse X") * xSensitivity;
yRot -= Input.GetAxis("Mouse Y") * ySensitivity;
		
Vector3 newRot = new Vector3(yRot, xRot, 0);
		
transform.localEulerAngles = newRot;

Anyone who can help me?

Many thanks!

Depends how do you want to link mouse to moviment.

You mey use transform.Rotate instead transform.localEulerAngles = newRot;

I found the answer for myself. I used Vector3.up and Vector3.left to generate rotation.

transform.Rotate(Vector3.up * Input.GetAxis("Mouse X") * xSensitivity);
transform.Rotate(Vector3.left * Input.GetAxis("Mouse Y") * ySensitivity);

Anyway, many thanks for the help!