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

HMD removed or put on

Discussion in 'AR/VR (XR) Discussion' started by vincismurf, Mar 26, 2018.

  1. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    I have noticed that this code only says the user in present with a Vive

    Code (csharp):
    1.  
    2. if (XRDevice.userPresence == UserPresenceState.Present)
    3.         {
    4.             Debug.Log("XRDevice.userPresence Present");
    5.  
    6.         } else if (XRDevice.userPresence == UserPresenceState.NotPresent)
    7.         {
    8.             Debug.Log("XRDevice.userPresence NOT Present");
    9.         }
    10.  

    Correction this works, you just have to wait 10/20 seconds for the state to change

    Thanks
     
    Last edited: Mar 26, 2018
  2. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    I can confirm this in Unity 2017.3.1f1 – it takes about 10 seconds, with the Vive HMD lying on the table, before XRDevice.userPresence changes from "Present" to "NotPresent," which is a problem when we want to run this check once at startup.
     
    manuel_garcia likes this.
  3. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    The work around is to do detection with the Vive's Proximity Sensor
     
    nickfourtimes likes this.
  4. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    219
    Right, that works thanks; for the moment I'm just replacing XRDevice.userPresence with the following:
    Code (CSharp):
    1. var mounted = SteamVR_Controller.Input(0).GetPress(Valve.VR.EVRButtonId.k_EButton_ProximitySensor);
    This works fine, though I feel like XRDevice.userPresence should be made consistent with this (rather than "poll the headset and set it to NotPresent after 10 seconds of inactivity").
     
    codestage likes this.
  5. Tudor

    Tudor

    Joined:
    Sep 27, 2012
    Posts:
    150
    This no longer works with the last big steamvr update. There's no documented way to access the `k_EButton_ProximitySensor`
     
  6. vincenzobafaro

    vincenzobafaro

    Joined:
    Nov 10, 2017
    Posts:
    5
    Hi guys, do you know how can do the same on the Oculus Go? I've tried but it doesn't work..
     
    Propagant likes this.
  7. vincismurf

    vincismurf

    Joined:
    Feb 28, 2013
    Posts:
    200
    Not sure but since Go is running on Android, I would think the standard Application pause methods should work
     
  8. Tudor

    Tudor

    Joined:
    Sep 27, 2012
    Posts:
    150
    EyePD likes this.
  9. Propagant

    Propagant

    Joined:
    Nov 18, 2013
    Posts:
    38
    Hey guys, I was wondering if the XRDevice.userPresence works for Oculus Go. Any ideas? Thanks