Camera Rotation using Gyroscope: Yaw and Pitch reversed

Hi,

I found some code that uses Input.gyro.attitude to rotate the camera. It’s working, however the Yaw and Pitch are reversed. The pitch is rotating left/right and the Yaw is up/down. Here is the code in the Update function.

Quaternion offsetRotation = Quaternion.Inverse(gyroInitialRotation) * Input.gyro.attitude;
cam.transform.localRotation = initialRotation * offsetRotation;

In the Start function I am setting the initial rotations.

initialRotation = transform.rotation; 
gyroInitialRotation = Input.gyro.attitude;

I am on iOS. Can someone please let me know how I can flip the Yaw and Pitch. If possible, I would like to not allow roll.

Thanks Much

phoberman has a nice gyro script that may help. it works well on iOS, but has been off and on flipped by a quat, due to Unity being inconsistent and sloppy in their Android updates.

http://forum.unity3d.com/threads/98828-sharing-gyroscope-controlled-camera-on-iPhone-4?p=849438&viewfull=1#post849438

I used some examples of reply and unity to made this code, and him works fine to me:

float yRotation;
float xRotation;
void Start{

Input.gyro.enabled = true;
}
void Update{
yRotation += -Input.gyro.rotationRateUnbiased.y;
xRotation += -Input.gyro.rotationRateUnbiased.x;

transform.eulerAngles = new Vector3(xRotation, yRotation, 0);
}