Skip to main content
Up and Coming
Aug 14, 2016 5:37 PM UTC
Solved

Detecting Oculus HMD is removed

While running and with an Oculus HDM attached does anyone know of a way to detect if the user/player has removed the headset? I'm trying to setup a script to trigger rendering on screen instructions to the desktop display and then reload the scene once a new player puts the headset on to restart the experience in a multi user scenario.
This topic has been closed for replies.
Inspiring
Aug 14, 2016 9:06 PM UTC
You can register delegates for the HMDMounted and HMDUnmounted events through OVRManager.

OVRManager.HMDMounted += HandleHMDMounted;
OVRManager.HMDUnmounted += HandleHMDUnmounted;

void HandleHMDMounted() {
   // Do stuff
}

void HandleHMDUnmounted() {
   // Do stuff
}


7 replies

Inspiring
Aug 14, 2016 9:06 PM UTC
You can register delegates for the HMDMounted and HMDUnmounted events through OVRManager.

OVRManager.HMDMounted += HandleHMDMounted;
OVRManager.HMDUnmounted += HandleHMDUnmounted;

void HandleHMDMounted() {
   // Do stuff
}

void HandleHMDUnmounted() {
   // Do stuff
}


L4Z3RC47Author
Up and Coming
Aug 24, 2016 5:15 AM UTC
Cool, thanks!
New Participant
Aug 24, 2016 11:36 PM UTC
I have tested this in editor (along with VrFocusAcquired and VrFocusLost), and it works fine.

But it does not work in my build.

I'm running 5.4.0p2 with OVR 1.7 and Utilities 1.7

Is this a bug? Or is there a setting I'm missing?
Inspiring
Aug 25, 2016 3:54 AM UTC
The last build I made where I know that this worked was Unity v5.4.0p1, Oculus Utilities v1.6.0, OVRPlugin v1.6.0. I haven't tried a build using 1.7 utilities/plugin.
New Participant
Apr 4, 2017 9:07 AM UTC
Has anyone managed to get this (or any other method for that matter) to work? Whatever I do, if user takes off the HMD, screen goed black, Unity goes suspend and there's nothing I can do about it??
L4Z3RC47Author
Up and Coming
Apr 4, 2017 6:17 PM UTC
@Corstiaan
@imperativity

You need to set the internal static bool "runInBackground" to true inside the OVRManager script 
New Participant
Aug 22, 2017 4:21 PM UTC
You can use the isUserPresent instance from the Oculus Utilities. We
have created a package which includes different analysing tools for the
GearVR and the Cardboard. https://www.assetstore.unity3d.com/en/#!/content/97173