Android Gyroscope not working ?

Hello there !

I’m currently working on an Android project and for the very first time I have to use Gyroscope. So far, touches have been working pretty well, the same does not go for Gyroscope though. In fact, whether I run my application through Unity Remote or build it to my phone (an Xperia U), it just does not work.

Here is my test code :

using UnityEngine;
using System.Collections;

public class GyroscopeDataDisplayer : MonoBehaviour {
	Gyroscope m_gyroscope;
	// Use this for initialization
	void Start () {
		m_gyroscope = Input.gyro;
		m_gyroscope.enabled = true;
	void OnGUI()
		GUILayout.Label("Gyroscope attitude : " + m_gyroscope.attitude);	
		GUILayout.Label("Gyroscope gravity : " + m_gyroscope.gravity);	
		GUILayout.Label("Gyroscope rotationRate : " + m_gyroscope.rotationRate);	
		GUILayout.Label("Gyroscope rotationRateUnbiased : " + m_gyroscope.rotationRateUnbiased);	
		GUILayout.Label("Gyroscope updateInterval : " + m_gyroscope.updateInterval);	
		GUILayout.Label("Gyroscope userAcceleration : " + m_gyroscope.userAcceleration);

Am I doing something wrong ?

Thanks in advance for your help ! :slight_smile:

Put this in your Start() function

Input.gyro.enabled = true;

I believe you need to use the Input.acceleration command instead of the Input.gryo. I use it and it works fine.

function Update () {
	var dir : Vector3 =;

	// we assume that the device is held parallel to the ground
	// and the Home button is in the right hand

	// remap the device acceleration axis to game coordinates:
	//  1) XY plane of the device is mapped onto XZ plane
	//  2) rotated 90 degrees around Y axis
	dir.x = -Input.acceleration.y;
	dir.z = Input.acceleration.x;