Search Unity

Gyroscope Game

Discussion in 'Scripting' started by theste1234, May 5, 2015.

  1. theste1234

    theste1234

    Joined:
    May 4, 2015
    Posts:
    1
    hi all,

    I am starting my first project and I am going to make a marble game that uses the gyroscope on the device.
    I used the simple bit of code (http://docs.unity3d.com/ScriptReference/Gyroscope-attitude.html) on a GameObject and it works on my android via unity remote.

    Now when I start the project, the object always starts on a slant (the device is level ground) and I would like it do start level to the device/camera. Can somebody please point me in the right direction on how to sort this out please. I am new to all this and would like one or two pointers.
     
  2. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    How much of a slant? Is it like 90 degrees, or just a slight one? Gyroscopes are not necessarily perfectly accurate so you might get a slight slant even when lying flat.

    You could try doing some kind of deadzone, so you need to rotate beyond a certain amount before your object reacts. You can also try to calibrate it, by storing the initial rotation and designating this as zero.
     
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,435