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

Oculus Quest wrong floor position?

Discussion in 'VR' started by R1PFake, Jun 28, 2019.

  1. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    533
    Im using the built in Unity XR classes. I have a very basic setup 2 controller with a TrackedPoseDriver (Left, Right) and a Camera with a TrackedPoseDriver (Head). I started the project on PC and everything worked fine with this basic setup, correct floor/height etc.

    But it seems that there is a issue with Oculus Quest, because im using the same setup (same scene) and when I start the app on the Quest the floor is way too low, it almost feels like the floor is at the headset height instead of the tracking floor.

    Are there any known issues with the XR classes and Oculus Quest?

    Im using Unity 2019.3.0a7.

    The VR "rig" (TrackedPoseDriver) are setup correctly, because as I said, the same setup works with PCVR (Vive).
     
    ROBYER1 likes this.
  2. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    533
    I think I found the "problem".

    For some reason the XRDevice TrackingSpaceType is set to Stationary as default for the Oculus Quest (which makes no sense in my opinion) so the head position is set at the floor position.
    But it's possible to change the TrackingSpaceType to RoomScale (XRDevice.SetTrackingSpaceType returns true) and then the tracking floor/head position is correct.

    So it's good that there is a workaround, but im not sure how the default TrackingSpaceType is set, but it should be RoomScale for the Oculus Quest in my opinion.
     
    cgiguy, MoMonay, BrainSlugs83 and 4 others like this.
  3. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    Absolutely baffling as to why it's not roomscale- I will submit a bug report for this else it will not be fixed!
     
  4. PMC0919

    PMC0919

    Joined:
    Sep 8, 2019
    Posts:
    13
     
  5. PMC0919

    PMC0919

    Joined:
    Sep 8, 2019
    Posts:
    13
    Hi. I am not great with the scripts yet in unity. Just using it with sketch up models and trying to make VR walkthroughs. Any chance you could explain where the room scale script should go and how to set it out please?
     
  6. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    Sorry I must have missed this reply, did you still need help with this?
     
  7. MonikaPeters

    MonikaPeters

    Joined:
    Oct 10, 2019
    Posts:
    13
    Can anyone explain how to set out the walking route through VR?
     
  8. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    Do you mean setting the room scale tracking mode?
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Tracking mode on quest is still false for me no matter what, standing, sitting, gyrating. Bugs are bugs I guess. I sent a case but others may not be experiencing the same thing depending on what API they are using, and there are 3 which supposedly work at the same time:

    oculus, unity engine XR and plugin XR. So you can't assume a case for you works for others. Please report a bug if it's not working as intended.
     
    ROBYER1 likes this.
  10. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I've got it to work by just calling it every frame and hoping for the best basically... not really sure if that's OK.
     
  11. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    It just needs to be called once!
     
  12. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    You can see here how the default setting of tracking space on the Quest puts the head at the floor by default, whereas if we override the tracking space type via script it is then at the correct height. This issue is being flagged to the QA team.

    Forcedroomscaleonviascript.PNG defaultsetting.PNG
     
    BrainSlugs83 and hippocoder like this.
  13. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    That's just it though.... calling it once makes it still kiss the floor. Calling per frame eventually shakes it loose to work as it should :/ crazy right?
     
  14. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    Are you able to share an example of this or even just the player prefab you are seeing this happen on? Sounds very wrong to me or like you have another update function resetting the state of the room scale tracking. Also check you don't have a rigidbody on the mesh using gravity or being pushed down by a collider.
     
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I think it defaults back to HMD whenever you switch your guardian, which can happen frequently in a house with a smaller roomscale... or even if you pick your headset up a bit later than you should and so on. Interruptions to it, even small, set it off cos somewhere Unity side it keeps assuming the default is standing/sitting and not roomscale. Or it keeps defaulting to HMD and not floor.

    It does this if you change guardian zones for me.
     
  16. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    That makes perfect sense, by default the tracking type should be room scale really as it always knows where the floor is, I have raised it to QA with an example project.
     
    BrainSlugs83 likes this.
  17. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Really hope you get a 2080 for all these reports I'm too slow / fat to make :D (and thank you)
     
    BrainSlugs83 and ROBYER1 like this.
  18. VirtualPierogi

    VirtualPierogi

    Joined:
    Sep 3, 2012
    Posts:
    54
    Same problem same setup, is there a way to get info about getting in/out of guardian? The room tracking should be set again to true whenether you come back to the game.
     
  19. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    Since moving to Unity 2020.1 alpha and enabling Oculus Link or updating my Quest this month, my builds all have my head in the floor again, back to square one :(
     
    Last edited: Nov 29, 2019
  20. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    Did you get a report on what version of Unity they fixed your issue with tracking space type and the timing of Unity registering it with the Quest? I think the issue is back on Unity 2020 alpha or the behaviour has regressed
     
    BrainSlugs83 likes this.
  21. nomand

    nomand

    Joined:
    Dec 23, 2008
    Posts:
    44
    There was a post somewhere around from a Unity dev that found a bug and put up some workaround code that if you wait for 1 frame before initializing roomscale through code, it should work. But doing it in awake/start gets reset after the first frame for some reason. So chuck your XRDevice.SetTrackingSpaceType setting into a coroutine and yield for a frame before setting.
     
  22. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    Thanks for this, it's obviously not ideal and hopefully the issue will be fixed engine side so it works with Start or Awake.. Start would be great at least and if it doesn't work in Start, a lot of devs will be confused
     
  23. gamemaker355

    gamemaker355

    Joined:
    Jun 27, 2019
    Posts:
    3
    I can't seem to find the XRRigFloorOffset script anywhere within my project.
    What would be the location for it?
     
  24. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    It's just a script I wrote!
     
    BrainSlugs83 likes this.
  25. BrainSlugs83

    BrainSlugs83

    Joined:
    Jun 18, 2015
    Posts:
    38
    Taking the approach detailed in this thread, I threw together my own script that works (on the Oculus Quest at least): https://pastebin.com/DC5LGD4S

    It's using `TrackingOriginModeFlags` instead though (since `XRDevice.trackingOriginMode` is deprecated and does not work on the Oculus Quest).

    It basically just loops in a coroutine and tries to set the tracking mode -- the delay it yields between tries grows bigger and bigger. (It always checks the current mode before resetting it too.)

    If successful, the maximum delay will increase to every 5 seconds (so that if the app is minimized and then re-opened, it will eventually still go back to the correct mode); if it's unsuccessful, the maximum delay is 1 second (so that it tries more frequently to complete the setup).

    If there's no VR subsystem found, it never does anything (not even run the coroutine). So, running from within the Unity editor won't be impacted.

    Btw, it also has a static readonly property `IsVrSetup` that will return `true` once it is able to set the tracking mode; that way other scripts can check if VR is ready or not. (This is similar to what the Oculus libraries/prefabs did on their own, some scripts just check in update to see setup has completed or not and return early if not.)
     
  26. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Thank you for that code, @BrainSlugs83! I found that just calling
    XRDevice.SetTrackingSpaceType(TrackingSpaceType.RoomScale)
    resulted in the camera reporting a position well over 3 meters high (even though the tracked hand positions were correct). But using your code, I get a much more realistic height (about 1.68 in my case).
     
    ROBYER1 likes this.
  27. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Drat, I spoke too soon. Using the code linked above, my head coordinates are quite reasonable, but now my hand trackers are reporting values below 0, unless I wave my hands in the air like I just don't care. Then the VR hands poke just barely above the floor. In other words, they're about a meter and a half too low.

    I'm getting the hand positions like so:

    Code (csharp):
    1.  
    2.            Vector3 localPosition;
    3.            device.TryGetFeatureValue(UnityEngine.XR.CommonUsages.devicePosition, out localPosition);
    4.            Quaternion localRotation;
    5.            device.TryGetFeatureValue(UnityEngine.XR.CommonUsages.deviceRotation, out localRotation);
    6.  
    7.            handTransform.localPosition = localPosition;
    8.            handTransform.localRotation = localRotation;
    where handTransform is parented under the same Camera Offset object as the camera. Have I done something not compatible with these newer APIs? Or is there some reason the tracking space of the hands should be different from that of the camera?

    (EDIT: I also tried disabling this code and using a TrackedPoseDriver, but it showed exactly the same behavior.)
     
    Last edited: Sep 30, 2020
  28. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Well. It's public-embarrassment day for me, apparently. Turns out that @BrainSlugs83's code was doing nothing at all on my system; it fails to find any XR Subsystems (on Oculus Quest), and so gives up right away. The weird effect I was seeing with the camera OK and the hands too low was just what I got out of the box. And when I set the tracking space to RoomScale, then the hands are OK but the camera was too high.

    BUT, that was using the default, automagical camera tracking (no components added to the camera at all). It turns out that if I add a TrackedPoseDriver to the camera, then it works correctly again, even with tracking set to RoomScale. As for the hands, I can either do it myself with the code posted above, or use TrackedPoseDrivers for them too.

    Hopefully all this helps the next poor schmuck who comes along with similar tracking woes.
     
    gjf likes this.
  29. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,450
    I believe if you don't have a tracked pose driver on an object, it won't follow the device used to control it. Unity switched off automatic camera control with the headset before 2019 engine version I thought.

    Was it not a noticeable issue that the camera wouldn't rotate with the head either or did it still rotate with your head?
     
  30. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    No, the camera still tracks with the head automatically (I'm using 2019.3.9f1). It just doesn't appear to do so in quite the same way as the TrackedPoseDriver.
     
    ROBYER1 likes this.
  31. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    186
    You can do the following on start (no need to wait a frame or the like):
    * unity 2019.4.10f1
    * inititlaizeXR on Startup must be checked in the Oculus Plug-In Management

    Code (CSharp):
    1.            
    2. List<XRInputSubsystem> lst = new List<XRInputSubsystem>();
    3. SubsystemManager.GetInstances<XRInputSubsystem>(lst);
    4. for (int i = 0; i < lst.Count; i++) {
    5.    lst[i].TrySetTrackingOriginMode(TrackingOriginModeFlags.Floor);
    6. }
    7.  
     
    methusalah999, zezba9000 and fuzzy3d like this.
  32. tpaslou

    tpaslou

    Joined:
    Mar 30, 2018
    Posts:
    10
    Did anybody find a solution that works ? I have the same problem. My build works fine for Rift S , but for Quest the camera is grounded.
     
  33. louspawn10

    louspawn10

    Joined:
    Dec 5, 2018
    Posts:
    6
    For me at least the issue was that my previous script was using the function SetTrackingSpaceType which is obsolete for 2019.3 and newer, it has been replaced with the TrySetTrackingOriginMode of the XRInputSubsystem.

    A quick and ready to use solution is to add the CameraOffset script of the XR Legacy Input Helpers package on the camera rig and use its settings for the tracking mode. The script handles the different Unity versions and uses the correct parameters and function calls.
     
  34. kontakt_unity924

    kontakt_unity924

    Joined:
    Aug 8, 2020
    Posts:
    6
    I solved this just by placing the XR Rig to Positon Y 0.
     
  35. cbxpounce

    cbxpounce

    Joined:
    Mar 7, 2021
    Posts:
    1
    Take this with a grain of salt, I'm completely new to VR dev or really Unity for that matter...So I'm here fiddling with "cubes and spheres on a floating table" tutorials still.

    That said, my scene when viewed through my Quest 1 appeared to position my head where I expected when connected via Link and hitting Play in Unity. I tried my first Quest build the other day and found my face embedded in the floor, as others have described in this thread. This was built using an XR Rig and some 2020 build of Unity and tried a number of suggestions out there. I upgraded the project to 2020.2.7f1 today so unclear if related. I found I can get my face at the expected height via both Link and when installed as an app on the Quest when I have the XR Rig's Tracking Origin Mode = Device, but also copy the "Camera Y Offset" value associated with it into the Y-position of the "Camera Offset" child component hanging off the XR Rig. Feels like the "Camera Y Offset" associated with "Device" is ignored when installed on a Quest. No idea what side effect this might have, but it helps anyone or if anyone can offer up what the side-effect might be that I'll run into later I'd appreciate that also.
     
  36. elmomalio

    elmomalio

    Joined:
    Jun 21, 2017
    Posts:
    1
    error CS0246: The type or namespace name 'XRInputSubsystem' could not be found (are you missing a using directive or an assembly reference?)

    Thanks for your proposition. However obviously it may not work without noting Which namespaces to use please.
     
  37. swedishfisk

    swedishfisk

    Joined:
    Oct 14, 2016
    Posts:
    57
    So I ran into this as well, I noticed that while running apk on Quest 2 the logs indicated the XR system was restarted some time after Start and first couple of Updates which I suspected could reset the TrackingOriginMode.

    So I can confirm it works if you keep spamming TrySetTrackingModeOrigin to Floor, but sure would be nice if we can figure out a cleaner way to do it.
     
  38. FishStickies94

    FishStickies94

    Joined:
    Jul 27, 2019
    Posts:
    70
    So is this still not fixed? Just tried to use Oculus XR on the Quest 2 and yep, player is in the floor unlike on PC. Would of thought an issue in 2019 would be sorted by now.
     
  39. robertoestradaleyva

    robertoestradaleyva

    Joined:
    May 4, 2018
    Posts:
    2
    For everyone who is still getting this error. The OVRManager has a parameter that will set this on the Oculus Integration v47.0.0 (maybe is on earlier versions, that’s the one I am using). Setting Tracking to "Floor Level" fixed the issue for me. The default is "Eye Level" which was causing the wrong spawn position. This happens if I use the Oculus XR plugin, not the OpenXR plugin

    upload_2023-1-11_9-33-19.png
     
  40. Entretoize

    Entretoize

    Joined:
    Feb 27, 2015
    Posts:
    57
    That's sill buggy, with floor level, with the rig at 0,0,0, the height is still random !!!