Hi all,
I have a simple gimbal lock issue :
float X = 0.0f;
float Y = 0.0f;
float Z = 0.0f;
myobject.transform.localRotation = Quaternion.Euler(X, Y, Z);
If I put “X = 90.0f”, then Y = Z 
I need to lock one axis on my script :
myobject.transform.localRotation = Quaternion.Euler(myobject.transform.eulerAngles.x, 0, myobject.transform.eulerAngles.z);
Maybe there is another way to do that ?
For one, don’t read back .eulerAngles, for the very reason of gimbal lock. It’s okay to read them once but once things get tumbled, they are not reliable.
For multi-axis rotating, it’s always best to parent multiple Transforms together so that each one only controls one axis. For instance, a battleship gun would have the first transform rotate around Y (face all directions on the compass), and then a child object would be the gun turret, which would rotate around its local X axis for elevation (how high up to fire).
Here’s some more thoughts on it: Turret aiming/rotating:
https://discussions.unity.com/t/783469/2