I want to make the game goes back to main screen 3 seconds later after the player take off the headset.
Maybe detecting whether the camera rotating will work…? (Still, don;t know how to detect that…)
I’m beginner so it’s hard to find which way is effective. If you have any advice, please let me know.
If you use the new input system you should be able to make an action for HMD removed from head
Sadly I don’t use the new input system … Should I? Looks like I don’t even know what I need to know. :0
Guess I found the solution…!
1 Like
The analogy to this solution for OpenXR does not work because of a bug in which you don’t receive the HMD removed event until AFTER the headset is put back on!
But after a day of struggle I finally found a solution. You simply poll the velocity of the HMD and when it is Exactly a zero vector the user has taken off the HMD
void Update()
{
if (HMDFound)
{
Vector3 velocity;
inputDevice.TryGetFeatureValue(CommonUsages.deviceVelocity, out velocity);
var hmdMounted = velocity != Vector3.zero;
if (hmdMounted != lastHmdMounted)
{
go.SetActive(hmdMounted);
OnUserPresence(hmdMounted);
lastHmdMounted = hmdMounted;
}
}
else
{
var inputDevices = new List<InputDevice>();
InputDevices.GetDevices(inputDevices);
foreach (var device in inputDevices)
{
if (device.characteristics.HasFlag(InputDeviceCharacteristics.HeadMounted))
{
inputDevice = device;
HMDFound = true;
}
}
}
}
1 Like
hi, may i know if i can apply this coding in openXR? and i dont understand where i can implement this coding into my vr simulator in unity.