Translating Compass Heading to Camera Yaw (Unity 3.5)

Hi guys!

Now that it is possible in Unity 3.5 to natively check the compass data of your device, I wanted to use that data for an Augmented Reality-application. The idea was to use the accelerometer & the compass to rotate the camera (my device lacks a gyroscope). I’ve already successfully linked the pitch & roll to the accelerometer and now I wanted to link the yaw to either Input.Compass.magneticHeading or Input.Compass.trueHeading.

As long as the device is held parallel to the ground, those readings output a value between 0 and 360 degrees, just what I need. The problem is that, once the device is held in front of you, as you would except in an Augmented Reality app, those values change. The script reference mentions that “the value in this property is always measured relative to the top of the screen in its current orientation”, but I can’t really figure out what that exactly means. I guess I’ll have to compensate for those differences using the data from the accelerometer, but I haven’t got a clue how that would precisely work. Any ideas?

I also looked at Input.Compass.rawVector, but I haven’t got any wiser from that, as it’s outputted in microTesla.

Have you seen this thread on the Unity forums:

http://forum.unity3d.com/threads/98828-sharing-gyroscope-controlled-camera-on-iPhone-4/page2

“the value in this property is always measured relative to the top of the screen in its current orientation” means the somehow that the heading values are intended to be used while the device is parallel to the ground, like a compass. It is possible to claculate the heading for other positions from Input.Compass.rawVector, I am working on it at the moment.