Any ideas that might help me do what I’m trying to accomplish would be greatly appreciated. Here is the code I am using in the Update method:

if (Input.GetKeyDown(KeyCode.Q))

{

transform.Rotate(Vector3.up * cameraRotationAngle, Space.World);

}

if (Input.GetKeyDown(KeyCode.E))

{

transform.Rotate(Vector3.up * -cameraRotationAngle, Space.World);

}

The problem is this is producing some curious results with the z axis. The z axis appears to be rotated a small amount intermittently (usually after several key presses). I don’t believe this is floating point precision problem because it is off by whole numbers not just a few decimal points. I’ve tried using the eulerAngles value instead with the same code and it just produced similiar results. The only thing I can think of is that I’m getting the mouse input in the wrong place and it actually needs to go into another method. Oh and btw what I am trying to rotate by is 15 degree increments around the y axis (up direction).

Any help would be great.

Ok so, I’ve done some more research in to the problem and have discovered what I think is the problem of gimbal lock. I noticed that the “errors” that occur in the zaxis actually only occur when the rotation of the y matches the xaxis. See i am trying to make an isometric perspective camera (which is rotateable). So it seems that every 30 degrees (Euler Angles) the axis align and give this gimbal lock effect which I’m assuming why I’m always off by similiar values on the z-axis. Question is how do I go about fixing this. I’m investigating the use of Quaternion rotation but I’m a bit confused as to how I should go about doing this as I’m a little inexperienced with this area of mathematics. Does anyone know how I would go about getting the Quaternions corrected for the z-axis being 0 and the x axis being 30? I’ve tried this:

cameraRotation.y += CAMERA_ROTATION_INCREMENT;

transform.rotation = Quaternion.Euler(cameraRotation);

Where cameraRotation is a vector3 that holds the rotation values in EulerAngles (i.e. x = 30, y = (+ or -15), z = 0);

This does not seem to fix my problem. Will I have to go about setting these Quaternions manually to the correct values or is there an easy way to do this?