Search Unity

Best Gyroscope plugin

Discussion in 'AR/VR (XR) Discussion' started by Alexfedel, Nov 15, 2017.

  1. Alexfedel

    Alexfedel

    Joined:
    Sep 25, 2015
    Posts:
    15
    What is the best gyroscope plugin to control the rotation of the Unity camera on iOS and Android?
    It should run as smoothly as possible, maybe by using additional sensors like compass, accelerometer.

    I read about some problems using Input.gyro on android devices, so I do not know if I should use Input.gyro. It might also be not good enough because it uses only the gyroscope sensor.

    I also want full control over the image of the camera.
    I can not use Unitys Virtual Reality support because it always renders with two cameras in split screen, but I also want to be able to switch to a single camera.
     
    Last edited: Nov 15, 2017
  2. Alexfedel

    Alexfedel

    Joined:
    Sep 25, 2015
    Posts:
    15
    I found a possible solution using Unity Virtual Reality support:
    -Magic Window mode-
    camTrans.localRotation = XRInput.GetLocalRotation(XRNode.CenterEye);
     
  3. Egil-Sandfeld

    Egil-Sandfeld

    Joined:
    Oct 8, 2012
    Posts:
    72
    I'm at the same point in my project. Found that the gyro calculations using the XRNode.Head works quite well. With it comes the stereoscopic, two-camera overlay on my screen. Any idea to remove this, while keep using gyro calculations from InputTracking.GetLocalRotation(XRNode.Head) ?
     
  4. juanje_89

    juanje_89

    Joined:
    Feb 6, 2014
    Posts:
    22
    By following these steps: https://github.com/googlevr/gvr-unity-sdk/wiki/Switching-between-VR-and-non-VR-at-runtime you can configure to switch on/off VR modes at runtime.

    If you add 'none' to the possible VR SDKs on Player Settings in the first place, you get the normal behaviour of 1 camera, BUT, if you establish the VR SDK device through the line:

    XRSettings.LoadDeviceByName("cardboard");

    You get HeadTracking with 1 camera or magic window mode (https://docs.unity3d.com/Manual/VRDevices-GoogleVR.html)
     
  5. Egil-Sandfeld

    Egil-Sandfeld

    Joined:
    Oct 8, 2012
    Posts:
    72
    Awesome! I figured it out myself as well, and this is all great. So now I have the following:

    In Player Settings -> XR Settings:
    • Virtual Reality Supported Enabled
    • In SDKs: None, Cardboard

    In void Start():
    • XRSettings.enabled = false;
    • XRSettings.LoadDeviceByName("cardboard");

    In void Update():
    • camRigTransform.rotation = InputTracking.GetLocalRotation(XRNode.CenterEye);

    Now the next issue is to force orientation to portrait, as our apps usually run in portrait mode whilst needing great gyro data.. Afaik enabling VR Support locks the Landscape Left orientation in Player Settings...
     
    LuckyHamster likes this.
  6. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    Cardboard SDK 0.6 will allow toggling VR mode on and off, and allow for orientation changes:
     
  7. Egil-Sandfeld

    Egil-Sandfeld

    Joined:
    Oct 8, 2012
    Posts:
    72
    Thank you, the Cardboard SDK 0.6 works for Unity 5.6.0f3, but not for Unity 2017, which is what I need. Any ideas?
     
    ChristophGeske likes this.