Search Unity

Gyro not working

Discussion in 'Android' started by NickP_2, Feb 13, 2016.

  1. NickP_2

    NickP_2

    Joined:
    Jul 9, 2013
    Posts:
    61
    Hello guys,

    I've been unable to retrieve the gyro data from my android since unity 5.2 (Currently updated to 5.3.2f1).

    I'm using a nexus 5 with latest android version, and as for the code:

    void Start()
    {
    Input.gyro.enabled=true;
    }

    and in the update:

    void Update()
    {
    Input.gyro.attitude.ToString()
    }

    this is not the real code, but a snippet out of my project. This code runs on my phone, and sends the data to my pc. But it keeps returning 0, 0, 0, 0 ... Even when deploying an empty project to my android with just this code, showing the output of the gyro in a text field.

    Has anyone found a fix? Should I report this as a bug?

    Thanks
     
  2. NickP_2

    NickP_2

    Joined:
    Jul 9, 2013
    Posts:
    61
    apparently Input.Gyro is for iPhone only. When on android, use Input.acceleration and convert it to a Quaternion with Quaternion.LookRotation.