HMD Worn State and SteamVR

Sep 16, 2020.Knowledge
HMD Worn State and SteamVR
Article written by Branden T.

When making a VR application, it’s sometimes useful to know if the player is wearing the HMD or not. There’s a function and corresponding blueprint node called “Get HMD Worn State” for this purpose. It will return “Worn”, “Not Worn”, or “Unknown.” Most VR platforms have an API function we call to get this state information, and the results are usually fairly quickly updated. An exception to this may be SteamVR.

There are some caveats with SteamVR, like the HMD needs to always have tracking for it to change worn state and needs to move a distance of more than HMDWornMovementThreshold as defined in *Engine.ini. SteamVR has also always required a really long (~60s) period of inaction, and the HMD needs to have tracking for that entire time for it to send the VREvent_TrackedDeviceUserInteractionEnded event.

If you start the game with the HMD not being tracked and the worn state is “Unknown”, you have to move it into the tracking area so it is tracked, and leave it still (for up to 60s) to get it into the “Not Worn” state (when SteamVR sends the VREvent_TrackedDeviceUserInteractionEnded event) before it will go into the “Worn” state (when SteamVR sends the VREvent_TrackedDeviceUserInteractionStarted event). The Started event won’t happen if the HMD is in the “Unknown” state; it has to go to the “Not Worn” state once before SteamVR will send the Started event. It seems like this functionality is controlled on the SteamVR side (like the 60s timeout before going to the “Not Worn” state), and it does not appear that we can control it on the UE4 side.

So if you’re expecting the HMD’s state to update as soon as the player puts it on or takes it off, I’m afraid you’re not going to get that kind of immediacy with SteamVR, and you will also need to have the player put the headset down for ~1min in the tracking area if they accidentally start the game without the headset being tracked.