Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

IsHeadMountedDisplay returning false, running a packaged game with -vr command line argument

Reproduction Steps

  1. Create new C++ Project

  2. Create 2 new C++ classes: MyPlayerController and MyLocalPlayer

  3. Add the following code to log out the result of IsHeadMountedDisplayEnabled()


     virtual FString GetGameLoginOptions() const override;


 FString UMyLocalPlayer::GetGameLoginOptions() const
     UE_LOG(LogTemp, Warning, TEXT("LocalPlayer: VR: %d"), UHeadMountedDisplayFunctionLibrary::IsHeadMountedDisplayEnabled());
     return Super::GetGameLoginOptions();


     virtual void BeginPlay() override;


 void AMyPlayerController::BeginPlay()
     UE_LOG(LogTemp, Warning, TEXT("PlayerController: VR: %d"), UHeadMountedDisplayFunctionLibrary::IsHeadMountedDisplayEnabled());


  1. Create a Gamemode Blueprint and select MyPlayerController as the default Player Controller

  2. In the Project Settings select the Gamemode you just created as the default Gamemode class

  3. in Project Settings -> General Settings, select MyLocalPlayer as the default Local Player class

  4. Compile and Package the project for Windows

  5. Right click on the .exe of the packaged game and add a shortcut

  6. Add the -vr command line argument to the shortcut (Target: "C:...\WindowsNoEditor\MyProject.exe -vr")

  7. With the HMD plugged in and SteamVR running, start the packaged game via the shortcut

  8. Have a look at the the logs (...\WindowsNoEditor\MyProject\Saved\Logs) and search for "LogTemp"

Result: IsHeadMountedDisplayEnabled returns 0 for false

Expected: IsHeadMountedDisplayEnabled returns 1 for true

Product Version: UE 4.13
more ▼

asked Sep 22 '16 at 10:57 AM in Bug Reports

avatar image

249 26 36 71

avatar image Sean L ♦♦ STAFF Sep 26 '16 at 05:59 PM


I apologize for the delay. I am looking into this issue and will respond back as soon as I have new information.

Thanks for your patience.

avatar image Sean L ♦♦ STAFF Nov 28 '16 at 02:52 PM

Hey AllJonasNeeds,

Apologies for the delay, we've recently moved offices and gotten the Vive set up. Are you still experiencing this issue, and if so, have you checked to see if it is an issue in 4.14?

Thank you for your patience

avatar image AllJonasNeeds Nov 30 '16 at 09:27 AM

Hey Sean,

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():

 bool UVRFunctions::IsGameInstanceInVR()
     return UHeadMountedDisplayFunctionLibrary::IsHeadMountedDisplayEnabled() || FParse::Param(FCommandLine::Get(), TEXT("vr"));
avatar image Rudy Q ♦♦ STAFF Dec 14 '16 at 06:38 PM

Hello AllJonasNeeds,

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?


alt text

avatar image AllJonasNeeds Dec 15 '16 at 08:56 AM

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
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

Make it a great day

more ▼

answered Dec 15 '16 at 08:03 PM

avatar image

Rudy Q ♦♦ STAFF
47.4k 545 132 524

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question