Apologies for the delay, we’ve recently moved offices and gotten the set up. Are you still experiencing this issue, and if so, have you checked to see if it is an issue in 4.14?
I just tested it again with 4.14 in a new project following the reproduction steps in the original post. IsHeadMountedDisplayEnabled() ist still returning 0 for false.
For the project I am currently worknig on I have a workaround using my own function instead of IsHeadMountedDisplayEnabled():
I ran a quick test in blueprints to see if I could reproduce IsHeadMountedDisplayEnabled returning false when the headset is in use, however I could not reproduce this issue on our end. If you create a new VR template based project and add the blueprint from the attached image to the level blueprint (MotionControllerMap) and package the project out with the -vr command, do you still see this issue on your end?
I modified my project to include your Blueprint and added a Print String node on the Level’s BeginPlay node as well.
On Tick IsHeadMountedDisplayEnabled always returns true. But on BeginPlay inside the Level Blueprint IsHeadMountedDisplayEnabled returns false in a packaged project, that is started with the -vr launch option as outlined in the original post.
Edit: Here is an excerpt of the packaged project’s log, if anyone is interested in that.
[2016.12.15-08.45.38:693][ 0]LogAIModule: Creating AISystem for world Map
[2016.12.15-08.45.38:693][ 0]LogLoad: Game class is 'BP_Gamemode_C'
[2016.12.15-08.45.38:695][ 0]LogWorld: Bringing World /Game/Map.Map up for play (max tick rate 0) at 2016.12.15-09.45.38
[2016.12.15-08.45.38:695][ 0]LogWorld: Bringing up level for play took: 0.000909
[2016.12.15-08.45.38:696][ 0]LogTemp:Warning: LocalPlayer: VR: 0
[2016.12.15-08.45.38:697][ 0]LogTemp:Warning: PlayerController: VR: 0
[2016.12.15-08.45.38:697][ 0]LogBlueprintUserMessages: [Map_C_1] BeginPlay HMDEnabled: false
[2016.12.15-08.45.38:697][ 0]LogLoad: Took 0.024554 seconds to LoadMap(/Game/Map)
[2016.12.15-08.45.38:899][ 0]LogLoad: (Engine Initialization) Total time: 2.33 seconds
[2016.12.15-08.45.38:899][ 0]LogExternalProfiler: Found external profiler: VSPerf
[2016.12.15-08.45.38:899][ 0]LogExternalProfiler: Using external profiler: VSPerf
[2016.12.15-08.45.38:916][ 0]LogOcInput: OculusInput pre-init called
[2016.12.15-08.45.39:014][ 1]LogRenderer: Reallocating scene render targets to support 2240x1260 NumSamples 1 (Frame:2).
[2016.12.15-08.45.39:156][ 1]LogRenderer: Reallocating scene render targets to support 3024x1680 NumSamples 1 (Frame:3).
[2016.12.15-08.45.39:156][ 1]LogBlueprintUserMessages: [Map_C_1] LevelTick HMDEnabled: true
[2016.12.15-08.45.39:426][ 2]LogBlueprintUserMessages: [Map_C_1] LevelTick HMDEnabled: true
...
After further testing, I believe that this is working as intended. It appears that the begin play fires off before the HMD is enabled. If you place a delay after the begin play before calling “IsHeadMountedDisplayEnabled” you will see that it returns true. You could try using tick to check to see if it is enabled and stop when it returns true. I hope that this information helps.
Wow. This fixed it for me. But it’s been 4 years! There has to be a right way of checking this.
Even the FPS template checks this on BeginPlay (see screenshot)! And I just tested, it’s TRUE in play-in-editor and FALSE when packaged there too (running with -vr)! Version Version: 4.25.4-14469661