Hi guys,
I’ve written an app for viewing 360° panoramas. The app has a Google Cardboard mode, and a normal mode where you can rotate the camera either using touch input or using the phones/tablets gyroscope.
Now this app has been in the stores for a while now and everything was working fine.
Both in iOS and Android.
But recently more and more Android devices have been popping up, where my code for the camera rotation controlled by the gyroscope doesn’t work anymore.
The phones in question do have a gyroscope, and frustratingly the Google Cardboard mode works fine.
However Googles code is hidden in a dll, so I can’t see how they accomplish this.
Here’s a code snippet of the camera rotation code:
// current measurement:
Quaternion gyroMeasurement = Input.gyro.attitude;
gyroMeasurement = new Quaternion(-gyroMeasurement.x,-gyroMeasurement.z, -gyroMeasurement.y, gyroMeasurement.w);
gyroMeasurement = gyroMeasurement * Quaternion.Euler(90, 0, 0);
Vector3 euler = gyroMeasurement.eulerAngles;
// calculate the delta values between our current measurement and the first measurement.
// Update: we only want the offset on the y-axis. The x-axis should be the current gyro measurement.
Vector3 finalDeltaValues = new Vector3();
finalDeltaValues.y = euler.y -m_initialGyroMeasurement.y;
// add the small delta values to the original orientation of the camera.
float finalEulerValueX = euler.x;
float finalEulerValueY = m_currentEulerVec.y + finalDeltaValues.y;
// feed these values into a quaternion and then perform the movement.
if (bAnimated)
StartCoroutine(RotateCameraAnimation(transform, transform.rotation, Quaternion.Euler(finalEulerValueX, finalEulerValueY, 0), 0.3f, false));
else
transform.rotation = Quaternion.Euler(finalEulerValueX, finalEulerValueY, 0);
In Debug mode I can see that Input.gyro.attitude always returns 0,0,0,1 on these devices.
Can anyone point me in the right direction to get this working again?
Feel free to contact me if you need any more info.
Cheers,
Sebastian