- Home /
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.
Hello,
this is an old post but did you find any solution for your last work (calculate the heading from Input.Compass.rawVector) ?
thanks.
Answer by flarb · Mar 13, 2012 at 08:58 PM
Have you seen this thread on the Unity forums:
http://forum.unity3d.com/threads/98828-sharing-gyroscope-controlled-camera-on-iPhone-4/page2
Answer by TiG · Dec 27, 2012 at 12:04 AM
"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.
Hi, TiG. I am working currently at the very same thing. I know it's being a while, but did you manage to get the heading from Input.Compass.rawVector for other positions of the device?
Thank you!
Your answer
![](https://koobas.hobune.stream/wayback/20220613064615im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Plugins on Android 3 Answers
Is there a way to have Vuforia and ARCore in the same app? 4 Answers
Has anyone used the new .net 4.6 with ARCore and ARKit in production? 0 Answers
apply Transformation on augmented model ,apply transformation on individual target image 0 Answers
Problem with creating an app with Augmented reality 1 Answer