How to get mobile yaw angle for Unity gyroscope?

Viewed 320

I use Unity remote 5 to connect my phone to the Editor. I am reading the values Input.gyro.attitude.eulerAngles and am some-have confused. Because not matter how I orient my device, all angles change. I was hoping to get specific one that reflects the camera yaw rotation. Angle that would change only if I rotate my device like in image below and stay constant if I rotate it differently.

enter image description here

P.S. When I observe Debug.Log(gyroInp.attitude.eulerAngles), the Z angle keeps growing even phone stands still on table. From 276 to 350 and continues to grow. Is it because the earth is turning? :)

1 Answers

Unity Remote 5 (UR5) seems to be broken for reading gyro as indicated by this (more specific) issue in Unity's issue tracker: https://issuetracker.unity3d.com/issues/ios-13-dot-0-rotations-around-device-y-axis-does-not-work-when-rotating-a-device-and-using-remote

If I use the UR5 to read gyro attitude/acceleration in the editor it gives an initial value that is never updated but only repeated for each read after that. The actual build on my (iOS 14) device works as expected.

So the Unity Remote 5 is unfortunately broken for all things gyro, it may be an iOS specific issue.

Related