Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity 3D Gyroscope doesn´t work;

Discussion in 'Scripting' started by TheRefik, Jul 1, 2015.

  1. TheRefik

    TheRefik

    Joined:
    Mar 20, 2015
    Posts:
    1
    Hey guys. I have one problem. this is my code:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class rotation : MonoBehaviour {
    5.  
    6.  
    7.  
    8.     void Update()
    9.     {
    10.         Input.gyro.enabled = true;
    11.     }
    12.     void OnGUI()
    13.     {
    14.         GUI.Label(new Rect(10, 10, 500, 100), Input.gyro.attitude.ToString() + Input.gyro.gravity.ToString() +  Input.gyro.rotationRate.ToString() + Input.gyro.userAcceleration.ToString());
    15.     }
    16. }
    But values on my android mobile always return zero values.
    I tried Input.acceleration and it worked. But i need gyroscope, becuse i need rotate camera depend on device rotation.
     
  2. WheresMommy

    WheresMommy

    Joined:
    Oct 4, 2012
    Posts:
    890