I’m doing a script for a first person view camera that works this way:
When I right click and drag, the camera turns intro free mode so I can see around.
The problem here is the following:
If the camera rotates, for example, 15º by the X axis, and 15º by the Y axis, the Z axis rotation increases and the X decreases. The final result is that the camera can even roll over itself.
I need to do a rotation that does not affecte the Z axis, or keeps it at 0 all the time.
You could force this with code by setting the localEulerAngles every frame,
void LateUpdate()
{
Vector3 temp = transform.localEulerAngles;
temp.z = 0;
transform.localEulerAngles = temp;
}
There’s probably a more elegant solution that we could help you with if you share your code.
Thank you very much !! I just tryed it and it works exactly as I wanted. Probably existists a more “elegant” solution but this will work good enough for now.