We are currently going through the review process with Oculus and we are required to detect when a HMD is removed, in order to pause our game. We are using the latest Unity 2020.3, and OpenXR 1.1.1, and I cannot find an option in the Input Actions window to detect this? I can’t seem to find anything in the forums either. Any help on this would be appreciated.
I’m currently looking at this myself. you’ll want to make a new input action for /userPresence, however this seems to be a touch buggy, as it occasionally doesn’t register the event. you’ll also want your menu buttons to trigger the pause as well.
I set up an action for userPresence using the new input system. The event fires when the headset is put on, but not when it is taken off. This is using a Rift S and the Oculus XR plugin or the OpenXR plugin.
Could you send the binding text you are using for your action just so we can test your exact scenario? I will try it here locally in the mean time and see if I can reproduce it… Thank you
Tested this locally with Oculus OpenXR on the Oculus Runtime and was able to reliably detect the value userPresence. The binding I used was <XRHMD>/userPresence and used the following code to detect the state.
Ah, I think. was using action.performed += and then checking the context for whether performed was true or false (never got false). Maybe that was the problem. I’ll try what you posted.
I think the docs said to set that binding up as a button…correct?
I still haven’t gotten it to work. I have added the input action XRMD / UserPresence (generic; I have not found anything particular for Valve Index). And it seems that it does not generate any events. Not when putting the headset on or taking it off. Does anyone have it working?
Sorry so much!! my answer has been too short. I will try to explain myself better.
I have created an action in XRHMD Input Actions called Presence. This Input Action, from Action Type equal to Button. In its properties, the Binding is /userPresence
For the call to the script I use Player Input. With Behavior equal to Send Messages.
Finally, the script where where the event is expected to arrive (but nothing arrives), is very simple.
I am just familiar with the player input with bahavior script. I dont know whether the action is being enabled, or how it is listening for change, etc. Likely the issue lies somewhere in that logic as binding directly the action seems to work. I would need to see the project to be able to debug any further.
And ‘started’ and ‘performed’ are fired at the very begging, even though my headset is resting on desk. ‘canceled’ doesnt fire itself at all, but if I click on console window in Unity, all three fire at once, every following clicking game and console window fire these event again. It seems it doesnt react on actual headsed mounted or not. Am I reading this action incorrectly, is it in fact application focus, or am I doing something wrong?
I have also tried reading value, changing value type, tried most of actions I didnt know meaning for, and I just cant get it to work.
Im using unity 2020.3.17f1 with XR Plugin Management 4.0.7 and XR Interaction Toolkit 1.0.0-pre.5
Is it possible for you to report a bug with Help -> Report a Bug with a small sample project that demonstrates this? If you can please post the issue # here so we can look into it faster.