Unity secretly uses accelerometer when Input.gyro? (even with a legit device)

Hello,

Encountered an issue where Gyroscope works totally ok with iOS (in all orientations), using “Unity Remote 5” application, but when I switch to android, it seems to use acellerometer, even though I am using Input.gyro

Android Device: Samsung Galaxy S4;

iOS device: iPhone 5

if(Input.SupportsGyroscope == true){
    Input.gyro.enabled = true;
    Quaternion phone_world_rot = this.gyro.attitude;
}

When I put Android phone flat on the table, it starts giving undefined rotation around Earth’s gravity axis. It therefore must be using acellerometer. The if-statement is successfully entered.

I tested gyroscope in S4 on its own, by dialling a secret phone-number *#0*# then going into Sensors->Gyroscope->Graph. Both gyroscope and acellerometer seem to be working, and gyroscope had no issue of rotating around the gravity axsi.

It’s just that unity seems to “snoop-in” acellerometer behind the scenes instead of gyro, as seen in “Unity Remote 5” application.

Plz halp!

gyro.attitude is not only the gyroscope according to the comment from this guy in the unity forum Unity, and the Accelerometer vs. the Gyroscope: A Complete Guide so your assumption is apparently correct.

In Android there’s a sensor type ROTATION_VECTOR and that’s where this data comes from, so if that is misbehaving so will Unity’s gyro.attitude.

When the phone is flat the data will only be relatively consistent if the compass is functioning properly as well as the other two sensors. Does the diagnostic data look good on it as well, meaning the heading is following north? If it isn’t also make sure that your not in an area with another strong magnetic field (although you mentioned the iphone was fine and presumably your using the same area).

Most algorithms use something similar to posted below. Figure 5 on page 3 show you why the compass is important for the axis parallel with gravity (which is yaw on the figure). Without the compass the data on that axis would drift a lot.

http://franciscoraulortega.com/pubs/Algo3DFusionsMems.pdf