Why if I Rotate only 1 axis, it rotates the other 2 axis also?


I try to rotate with a certain value on a certain axis like X for example and the code is like this :

mouseY = Input.GetAxisRaw("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation -= mouseY;
followXRotation.rotation = Quaternion.Euler(xRotation,0f,0f);

I want to mention that the followXRotation is a child of the Camera which is a child of an empty GO and this script is attached to the empty GO.
This should work but when i Rotate on X axis, Y and Z axis will have small values like random values between (-11,11(just for example)) and then when i stop rotate, the values will be 0.

When i Rotate 2 axis there is no problem and the problem is when i rotate just one axis.
Does somenone knows how to solve this problem?

Try using localEularAngles and use mouseX in the X axis.

Ok I solved my problem with some help from @jimmiewalker653 suggestion.

followXRotation.localRotation = Quaternion.Euler(xRotation, 0f, 0f);

So you have to rotate around local axis.