- Home /
Gyroscope on windows phones. Enabled but no working
Hi everyone, I'm trying to use the gyroscope on my lumia 920 but without success.
In order to test it i made an extremely simple scene with this only this script attached to the camera:
using UnityEngine;
using System.Collections;
public class Gyro : MonoBehaviour {
private bool gyroBool;
private Gyroscope gyro;
private Quaternion rotFix;
private Vector3 initial = new Vector3(90,180,0);
// Use this for initialization
void Start () {
Screen.orientation = ScreenOrientation.LandscapeLeft;
Screen.sleepTimeout = SleepTimeout.NeverSleep;
gyroBool = SystemInfo.supportsGyroscope;
Debug.Log("gyrobool " + gyroBool.ToString());
if (gyroBool)
{
gyro = Input.gyro;
gyro.enabled = true;
rotFix = new Quaternion(0,0,0.7071f,0.7071f);
}
else
{
Debug.Log("no gyro support");
}
}
// Update is called once per frame
void Update () {
if (gyroBool)
{
Debug.Log (gyro.enabled);
var camRot = gyro.attitude*rotFix;
transform.eulerAngles = initial;
transform.localRotation *= camRot;
Debug.Log(gyro.attitude);
}
}
}
The log shows me that gyro is enabled, but the result of the attitude is Always 0 no matter how the phone is positioned.
I'm sure the gyroscope of the phone is working because i made also a simple app in visual studio 2012 following this guide https://msdn.microsoft.com/en-us/library/windows/apps/hh202943%28v=vs.105%29.aspx and it works nicely.
Where I am wrong? just to be sure i tried to build with both unity 4.6 and the new unity 5, but no differences
Your answer
Follow this Question
Related Questions
Windows Phone 8 & Gyro 1 Answer
Rotate objects towards gps coordinates 0 Answers
Android gyro 1 Answer
How to get the value of the an angle of the Gyroscope? 1 Answer