Using euler angles to rotate causes the object to get stuck on the x axis?

Hi everyone,

I wrote a simple script to rotate an object on its axis for the purpose of showing a 3D model. It was as follows:

transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z + 0.1f);

Where I would apply the +0.1f to whichever axis I wanted to rotate around.

The script worked fine with the y and z axis, but when applied to the x axis, the model rotated to 90 degrees and then kept jumping between 90 and 89.9. I solved the problem by using transform.rotation instead, but I would like to know why that code didn’t work for the future. The object in question is a point cloud rendered using the process from here

What you encountered is a Gimbal Lock and the exact reason why Unity is using quaternions for rotations and is only offering euler angles for easier access to them.