Search Unity

Oculus poor tracking after XRSettings.enabled = true

Discussion in 'AR/VR (XR) Discussion' started by BusterXXL, Aug 24, 2018.

  1. BusterXXL

    BusterXXL

    Joined:
    Aug 24, 2018
    Posts:
    1
    Unity 2018.2 / Oculus Rift

    I want the user to be able to switch between VR-mode or a non-VR (a plain screen) by simply putting on or removing the Oculus headset.

    I have managed to do this by using

    Code (CSharp):
    1.  
    2. if (XRDevice.userPresence == UserPresenceState.Present && XRDevice.isPresent)
    3.         {
    4.             if (!XRSettings.isDeviceActive)
    5.             {
    6.              
    7.                 XRSettings.enabled = true;          
    8.                 Debug.Log("User wearing HMD.");
    9.             }
    10.  
    11.         }
    12.         else
    13.         {
    14.  
    15.             if (XRSettings.isDeviceActive)
    16.             {
    17.                 XRSettings.enabled = false;
    18.                 Debug.Log("User not wearing HMD");
    19.             }
    20.   }
    21.  
    The first time I take the headset off and then on, it works fine.
    But the next time the headtracking stutters for some seconds, and then is OK. The frame rate of the rest of the game is fine.
    If I do it again, it takes longer for it to catch up with the head tracking. It seems that for every time I take it on, the longer it takes to recover.
    The Oculus program reports "Poor tracking quality" while this happens.
    It seems to build up a stack of instances of some sort that needs to be flushed every time XRSettings.enabled is set to ture.

    If I "unload" Oculus by loading
    XRSettings.LoadDeviceByName("None");
    when taking the HMD off,
    and then reload with:
    XRSettings.LoadDeviceByName("Oculus");
    it works fine.

    Only problem is that when device "None" is loaded, I obviously can not automatically detect when the user puts on the head set again, since I can't use
    UserPresenceState.Present


    Using a button or keyboard to trigger a reload is not an option for my case. (a public exhibition display)

    Is this a bug in Oculus, or am I missing something here?
     
  2. obuga

    obuga

    Joined:
    Sep 3, 2019
    Posts:
    3
    Did you manage to solve this thing? I have exactly the same problem.