Search Unity

Controlling the camera by the smartphone gyroscope - question ...

Discussion in 'Scripting' started by Asta_D, Nov 24, 2016.

  1. Asta_D

    Asta_D

    Joined:
    Oct 16, 2013
    Posts:
    15
    Hello

    I created a scene and i got it to run it on my galaxy s6, The camera is controled by the gyroscope, but its not so accurate. The horizont is tilting about 20 degrees, when i rotate around the y-axis.

    My code:
    Code (CSharp):
    1.     void Start () {
    2.         Input.gyro.enabled = true;
    3.     }
    4.    
    5.     void Update ()
    6.     {  
    7. transform.Rotate (-Input.gyro.rotationRateUnbiased.x, -Input.gyro.rotationRateUnbiased.y, Input.gyro.rotationRateUnbiased.z);
    8.     }
    How can i avoid this tilting?

    Greetings from Germany
    Asta