Gyro Rotation Offest Calculation or Alternate Solution?

So I have a script where I use the gyroscope data of an iPhone to turn a camera. As of right now, my script matches the camera’s rotation with a Vector3 with altered axes, and for vertical and horizontal movements from the initialized position (phone is flat with screen pointing up), the script works fine, i.e. I turn the phone left and the camera turns left, I turn it right and the camera turns right. However, a problem i’m having is that if I turn the phone 90 degrees left/right, and then turn it 90 degrees up/down, the camera barrel rolls instead of moving up/down. If anyone knows the mathematical formula for fixing this issue, or just has a better solution, please let me know. Thanks.

http://forum.unity3d.com/threads/gyroscope-quaternion-to-unity-camera-help-please.75288/ Basically having the same problem as this guy,

Hi @chiddaan, I am doing the same thing as you. Do you find solution to load object from bytes from url?

1 Answer

1

You may find it easier if you have a parent object which handles panning and then apply tilt to the camera child object. Just make sure you zero out the other two unused rotation axes on each object.

e.g. parentRotation Vector3(0, pan, 0)

childRotation Vector3(tilt, 0, 0)

Would I create an empty GameObject for the parent?

Yes @mbrindic I finished it. I was using Microsoft HoloLens, but the computing power of HoloLens is not good enough to do this heavy operation. Anyway, solution, I found an asset which worked well for me. Here's the link for it. https://www.assetstore.unity3d.com/en/#!/content/22195 It helps with objects having vertices, triangles or normals greater than 64k Good luck.