Download

Detecting whether a HMD is in use

I have asked this questiion a while ago on AnswerHub (Detecting whether a HMD is in use - UE4 AnswerHub) without success, but I’d be surprised if I’m the only one with this problem. Maybe someone here has a solution?

When loading my game, I want to select an appropriate character depending on if the player is using an HMD or not. In the editor, this works fine using the IsHeadMountedDisplayEnabled Blueprint node: it returns frue in VR preview and false otherwise. However, it always returns true when packaging the game, or when using a shortcut to UE4Editor.exe with my project file and -game as parameters.

I’ve tried other methods (GEngine->IsStereoscopic3D(), GEngine->HMDDevice->IsStereoEnabled(), GEngine->HMDDevice->IsStereoEnabledOnNextFrame(), GEngine->HMDDevice->DoesAppHaveVRFocus()), but they all return either always true or always false in standalone mode, and these alternatives do not even work properly with PIE, either.

So, what is the proper way to detect whether the game is running on a HMD? I.e. something that returns true when starting using -vr as a parameter or calling “Stereo On” and false otherwise. Or is this behavior a bug in IsHeadMountedDisplayEnabled, since the documentation “Returns whether or not we are currently using the head mounted display.” seems to imply this behavior?