How to toggle VR <-> PC

how to toggle vr ↔ pc

I’ve tried ExecuteConsolecommand(vr.bEnableHMD True, vr.bEnableStereo True) but it didn’t work.

how can I do this?

If you execute commands in C++ to do something that means you really doing something wrong, you need to search for proper functions for this. There should be something as console commands have access to exact same APIs as you do, C++ is not blueprint to do console commands.

In UEngine (which oyu access via GEnigne) there XRSystem pointer intefrace for VR/AR systems, from there you can access variority of functions related to HMD.

In there you got GetHMDDevice() and ferther in EnableHMD(bool). Note that moth XRSystem and HMDDevice can be null if those systems are missing, so do check to prevent crash.

You can also look up blueprint node source code of VR to see what to do to do something:

https://github.com/EpicGames/UnrealEngine/blob/8e4560b8c22b309e73ff0ce90377742c3dfe13cc/Engine/Source/Runtime/HeadMountedDisplay/Private/HeadMountedDisplayFunctionLibrary.cpp

Thanks

It works well in VR Preview, but not in the Viewport play

can I know why?