Mysterious rotation on z axis when I only change x & y. Why?

I need to make a custom camera rig and am starting w a simple FreeCamera in a container. My code is only changing the container’s X and Y…Z should always be zero.

Dragging in a circular motion changes X and Y as expected, but it also affects Z over time. Why is it doing this??

Try it; drag in a circular motion about a dozen or more times and you’ll see it slowly rotating on the Z axis:

One issue is that when you expand the Inspector to the left you will see that the full title is Rotation (Using Quaternion) so the values for X, Y and Z you see are not rotation values but the local axis values of the quaternion, the local angle value W is not shown.

Thanks @JohnK. I’m not totally following as I’m quite unfamiliar w Quaternions, but it sounds like I might be misunderstanding the Rotation values in the inspector? Regardless, my problem is still that I’m only manipulating 2 axis, but 3 axis are changing. Trying to understand if this is a bug or if I’m doing something incorrectly.

@Evgeni_Popov can you help here?

Maybe it’s a precision problem during the computation?

You may also update rotation.x / rotation.y directly instead of using rotate.

Yeah…that works:

I guess I’ll steer clear of rotate then. Thanks!