I’m stuck for a few days now and I just can’t wrap my mind around it. I want to keep the orientation of an Object fixed in real world 3D-space, making use of the gravity vector, that is provided by the gyroscope. Kinda like shown here @ min 1:30 https://www.youtube.com/watch?v=ORcu-c-qnjg.
I use Unity 3.5 and it would be OK, if I would get it working in just one orientation of the device (e.g. Portrait). I use the prime31 DeviceMotion-PlugIn, which gives me the values of Gravity X, Gravity Y, and Gravity Z, which I apply (multiplied by 90) to the eulerAngles of my Object. It looks promising but there is a mathematical problem involved, that I just don’t get.
Here’s my wrong approach, but just to describe the issue:
I apply the Gravity Y- value (by 90) to the rotation.x of my object. This keeps it looking up perfectly in real world 3D-space, when I tilt the device. But when I roll the device (without tilting) the Gravity Y- value does also change (and thus my object).
I know this is totally the wrong approach. But can anybody help me to bring the three Gravity-Values into the right mathematical context?
Thanks so much!