- Home /
Input.gyro.attitude returns zero value
Hi people, Recently I've been working on a project that works with gyroscope. Firs everything was fine until now my gyro.attitude returns zero like this:
I have tested it with unity remote and depoyed on my Nexus 5 itself, both return same error and so program doesn't work. Then I tried to deploy on my friend's phone and it worked again, but after some deployment my friend's phone failed too. Now we tested completely new projects in two different PCs, no result. I've formatted my Nexus 5 even changed OS to Lollipop and Marshmallow, no luck. I believe it is a hardware issue, because it is still working on any new phone... I have checked another programs that are using gyro and they worked on my phone. I'm still struggling to understand the origin of the problem. Anyone can help me from Unity? Or anyone who faced the same problem? My simplest code is like following:
using UnityEngine;
using System.Collections;
public class gyro : MonoBehaviour {
Gyroscope gyr;
// Use this for initialization
void Start () {
gyr = Input.gyro;
if (SystemInfo.supportsGyroscope)
{
gyr.enabled = true;
Debug.LogWarning("Gyro Enabled");
}
}
// Update is called once per frame
void Update () {
Debug.Log(gyr.attitude);
}
}
And Debug.Log returns something like this:
(0.0, 0.0, 0.0, 0.0)
UnityEngine.Debug:Log(Object)
gyro:Update() (at Assets/gyro.cs:21)
Answer by plolley · Nov 05, 2015 at 09:09 PM
I'm having the same issue. It looks like this will be fixed in 5.3.
For the record, the gyroscope doesn't work when trying to run with Unity Remote. So whenever you want to test gyro behavior, you'll need to do it only after deploying the app.
Your answer
Follow this Question
Related Questions
How to transform local space to world GYRO space on ios? 0 Answers
I would like to know if with a unity free is possible to use gyroscope android? 1 Answer
Gyroscope.attitude = GetComponent ().TransformDirection ? 1 Answer
Unity 3.4 Gyroscope support not there? 2 Answers
Input.gyro.attitude not working on newer Android devices 3 Answers