Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Question Detect headset removed

Discussion in 'VR' started by yessaad, Feb 8, 2021.

  1. yessaad

    yessaad

    Joined:
    Jan 14, 2021
    Posts:
    1
    Hi all,

    I'm a newbie developer and currently work for a museum.
    I want to control a 360 degree video without using the controllers.
    I am using the "isuserpresent" function to play / pause / stop the video. Everything works fine in the runtime (oculus Link) but when I build it doesn't.

    Does anyone have any idea where the problem is ?

    I work with Unity 2019.4 + Bolt + Oculus integration 23.1
     
  2. Tanya_Li

    Tanya_Li

    Unity Technologies

    Joined:
    Jun 29, 2020
    Posts:
    98
    Hey,

    You could try using CommonUsages.userPresence. https://docs.unity3d.com/ScriptReference/XR.CommonUsages-userPresence.html

    Example as below:
    Code (CSharp):
    1.        
    2. InputDevice headDevice = InputDevices.GetDeviceAtXRNode(XRNode.Head);
    3. if (headDevice.isValid)
    4. {
    5.     bool userPresent = false;
    6.     bool presenceFeatureSupported = headDevice.TryGetFeatureValue(CommonUsages.userPresence, out userPresent);
    7.     Debug.Log("presence feature supported " + presenceFeatureSupported + " userPresent is " + userPresent);
    8. }
     
  3. Ikaro88

    Ikaro88

    Joined:
    Jun 6, 2016
    Posts:
    264
    this works fine but not work with openXR on quest 2 (works on editor but NOT on build)
    Any way to let it work with OpenXR?
     
  4. AndreasWang

    AndreasWang

    Joined:
    Jul 31, 2019
    Posts:
    14
    You could make an OpenXR feature and override OnSessionStateChange() to check for user presence. The input parameters map to this enum, and you could consider XR_SESSION_STATE_FOCUSED as a state where the user is present