It can be quite a pain to go back and forth between vr and editor for testing. That situation gets even messier when your game supports VR and Non VR modes. In this post I’ll show you some tricks to make that process simpler.
You can set a master Boolean in your game instance to check if you’re running in VR mode or not by using the node “Has Launch Option”
In your game instance you would do something like this:
This option can be whatever you want. We’ll go over how to set this in the below topics. The quick answer is append it your shortcut file or call it from the command line.
Separate Game Ini Files
You may run into a situation where you want different options in your DefaultGame.Ini file based on being in VR or not. Well, you can actually have two different ini files! I made an additional ini file called DefaultGameVR.ini. You can call yours whatever you want.
This goes in your config folder with the other ini files. In order for the engine to package it with your game, you must white list it in the original DefaultGame.ini file like so:
In order to tell the engine to launch with these setting you can append it to your shortcut or to use it in the command line.
As far as I’m aware you can do this for other ini files as well.
Testing without packaging
Instead of packaging a build every time you want to test, you can launch your project in Game mode instead of editor mode. Normally you just right click on your .uproject file and “Launch Game”.
However, this does not load your launch options. Instead we run it from the command line by switching to the engine directory, directly referencing the .uproject file, and supplying our launch options.
The parameter -game tells the project to launch in game mode
The parameter -nohmd tells the game not to hook to your headset. This option is broken in several engine versions. You have to make sure you are running the source code version of the engine for this option to work on 4.23 and 4.24. 4.25 has this patched into the stock version. I do not know how far back engine version wise this bug exists.
If we want to launch with our VR options instead you’d do this:
The parameter -DEFAULTGAMEINI tells the engine to load a custom ini file. In this case it’s the one we made earlier.
The parameter -doVRStuff is our master Boolean we set in game mode. The engine will pick up and launch option you call like this.
Calling all this stuff from the command line can be tedious so I’ve made a batch script to make this process easier.
@echo off set ENGINE_ROOT=[LOCATION OF YOUR UNREAL ENGINE FOLDER] set PATH_TO_EDITOR=\Engine\Binaries\Win64 set PROJECTNAME=[SAME AS YOUR UPROJECT MINUS .UPROJECT] @echo title Launch Options :start @echo How do you want to launch? @echo 1: Non VR Mode @echo 2: VR Mode SET /P INPUT= Selection: IF "%INPUT%"=="1" (GOTO :NonVRMode) IF "%INPUT%"=="2" (GOTO :VRMode) :invalid cls @echo Invalid Input... GOTO :start :NonVRMode cls @echo Launching Non VR Mode.... %ENGINE_ROOT%\%PATH_TO_EDITOR%\UE4Editor.exe %cd%\%PROJECTNAME%.uproject -game -nohmd GOTO :end :VRMode cls @echo Launching VR Mode.... %ENGINE_ROOT%\%PATH_TO_EDITOR%\UE4Editor.exe %cd%\%PROJECTNAME%.uproject -game -DEFGAMEINI=DefaultGameVR -doVRStuff GOTO :end :end
Paste this into a batch file called whatever you want. Place the batch file in the same folder as your .uproject file.
Replace ENGINE_ROOT with the location of your unreal engine folder. Mine looks like this: ENGINE_ROOT=D:\Engines\UE_4.24_git\UnrealEngine
I believe the slash direction matters.
Replace PROJECTNAME with the name of your project. Mine looks like this: PROJECTNAME=EoD2
Ok so we can test from the project file. What about packaging? How do we do separate launch options there? We make shortcuts.
Make sure these go to the .exe in your binaries folder. It works for me not doing this, but best to be safe.
Inside each shortcut you would append options the same way we do in command line.
Make sure it’s all the way at the end of Target.
Steam Launch Options
Now you’ve got your multiple launch options. You want to have these show up in steam when you launch your game. To do that you must go to the steam dashboard.
Go to your general installation settings and set up launch parameters the same way we call in shortcuts or command line.
I don’t do it in the above section, but you can set up launch options that are separate from steam VR and oculus. I use the VR expansion plugin so I don’t have to do this as I build my content HMD agnostic.