Search Unity

Oculus Quest + OpenVR: get floor offset?

Discussion in 'AR/VR (XR) Discussion' started by Aaron-Meyers, Jul 31, 2019.

  1. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    176
    I'm working on a project on the Quest, but on my dev machine I have a Vive so I'm using OpenVR rather than the Oculus SDK. Is there some way to have the Quest builds offset from the floor properly the way the Vive automatically does when I'm testing in the editor? The Quest clearly knows where the floor is because the guardian stuff is set up, but it doesn't seem to want to use that in the tracking data. I tried throwing the TrackedPoseDriver onto the camera (Device:Generic XR Device, Pose Source: Head) to see if that might help, but it doesn't seem to change anything.
     
  2. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    176
    No one else out there trying to use Oculus Quest with OpenVR?

    Seems likely that its an issue where Oculus doesn't like to play nice with open platforms, but has no one found a workaround? I don't want to have people placing their controllers on the floor to calibrate every time!
     
  3. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    176
    for those wondering, the answer was:

    UnityEngine.XR.XRDevice.SetTrackingSpaceType( UnityEngine.XR.TrackingSpaceType.RoomScale );
     
    ROBYER1 and mattbenic like this.
  4. PMC0919

    PMC0919

    Joined:
    Sep 8, 2019
    Posts:
    13
    Aaron-Meyers, thank you for confirming the solution to the Quest tracking issue.
    I am just learning unity, but I am trying to use the Quest to walk inside my Sketchul models.
    Where would I need to add the code you posted here?
     
  5. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    176
    Anywhere really... you just want to call it once when your scene starts so I’d recommend putting it inside an Awake() method on any MonoBehaviour in your scene.
     
  6. PMC0919

    PMC0919

    Joined:
    Sep 8, 2019
    Posts:
    13
    Aaron-Meyers. Do I need to add it to an empty game object? And can I just have the code you showed:
    UnityEngine.XR.XRDevice.SetTrackingSpaceType( UnityEngine.XR.TrackingSpaceType.RoomScale );
    Or do I need to add....public class and a name etc, and also the brackets? {?
    I have looked at other scripts / codes that seem to have lots of info in them.
    This shows how little I understand, but to get it to work on my Quest I just need to know this one thing! For now.
     
  7. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    176
    Yes, it would need to be on a game object in your scene. Create a new C# script in Unity and name it whatever you want. You could just put that one line exactly as it is inside the Start() function that it will automatically create in the C# file. Then put that C# file you created on an empty game object in the scene.
     
  8. PMC0919

    PMC0919

    Joined:
    Sep 8, 2019
    Posts:
    13
    Thank you very much Aaron-Meyers. I will give that a go.
     
  9. PMC0919

    PMC0919

    Joined:
    Sep 8, 2019
    Posts:
    13
    Hi Aaron-Meyers, sorry I need your help again please. I have now got an error message: Assets\XRDevicetracking.cs(8,60): error CS1001: Identifier expected.

    I added your code in the following way....
    public class XRDevicetracking : MonoBehaviour
    {
    //Start is called before the first frame update
    Void Start(UnityEngine.XR.XRDevice.SetTrackingSpaceType(UnityEngine.XR.TrackingSpaceType.Roomscale);)
    {
    }
    // Update is called once per frame
    Void update ()
    {
    }
    }
    I assume I have got some brackets wrong?
     
  10. dwattintellisoft

    dwattintellisoft

    Joined:
    Apr 26, 2019
    Posts:
    8
    void Start()
    {
    UnityEngine.XR.XRDevice.SetTrackingSpaceType(UnityEngine.XR.TrackingSpaceType.Roomscale);)

    }

    you had the function call as a parameter
     
  11. PMC0919

    PMC0919

    Joined:
    Sep 8, 2019
    Posts:
    13
    Thank you dwattintellisoft
     
  12. PMC0919

    PMC0919

    Joined:
    Sep 8, 2019
    Posts:
    13
    i still can’t figure out the script! I still have error messages.
    Please see the photos attached of the errors and the code.
     

    Attached Files:

  13. Aaron-Meyers

    Aaron-Meyers

    Joined:
    Dec 8, 2009
    Posts:
    176
    try starting over and name your script something else. "new" is a reserved word in C# (and most programming languages) so using it for the name of a class is asking for trouble.
     
  14. PMC0919

    PMC0919

    Joined:
    Sep 8, 2019
    Posts:
    13
    Aaron-Meyers, thank you. But does the script seem ok? Or is there too many brackets etc?
     
  15. PMC0919

    PMC0919

    Joined:
    Sep 8, 2019
    Posts:
    13
    Now there is an error saying....
    Assets\XRDeviceTracking.cs(10,79): error CS0117:’TrackingSpaceType’ does not contain a definition for ‘Roomscale’