Switch between First Person and VR

Hello,

I’ve seen this question answered a few times now, but none of the answers seem to work for me.

I am trying to switch from the first person character to a VR Pawn and back during gameplay using Blueprints. I tried enabling HMD, using the console command “stereo on” and possessing the “Motion Controller Pawn” in the Level Blueprint. But when I play in editor, new window or standalone game it seems to possess the Motion Controller Pawn, but I can’t control him and he is stuck in the floor.1
I’m using the oculus rift with touch controllers.
Maybe I am overlooking something basic here?
Thanks in advance.

Hi
Hope someone will help, just got into the same issue.

I want to create a 2D menu from where the user could launch a VR level. When I start the preview my menu is there, and i ve a button to open the VR level that does the job but the level preview doesn’t switch to VR so nothing in the HMD and I can see the level on my screen stucked at my VRPawn location.

We have to switch the rendering to VR but I am not sure how to do that…yet.

1 Like

The console command you are look for is “vr.bEnableStereo” - add a 1 afterwards for enable and 0 for disable.

The way I’ve got it set up in a project is on my “VR_Start” event, I first enable the HMD, then run the console command “vr.bEnableStereo 1” then possess the pawn, remove the menu widget and finally set the input mode to game only.

In this example I have 2 VR pawns with different input methods and a Non-VR Desktop pawn: Posses VR or Desktop Pawn posted by jkelly206 | blueprintUE | PasteBin For Unreal Engine 4

The “control switch” variable is my menu widget. All these events are bound on “begin play” after spawning the menu widget and adding it to the viewport.

Hope this helps. If you can’t get it working, upload your blueprint to https://blueprintue.com/ and I’ll take a look.

2 Likes

Thanks , I’ll try that out and get back to you.
You’re right, Blueprintue.com is actually the best way to share blueprints for cases such as this. I knew about the platform, but I didn’t think to use it for this case.

Well I tried it with the console command and it still does not work. I do it in the level blueprint so that I can get an absolute reference to my 2 Pawns. Here is the link to the blueprint: Switch FPS to VR Pawn (not working) posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4
What happens: I start the game in First Person mode. I can move around interact with everything, just as it should be. Then I press V (right now this is my debug key to test this out) to switch to VR. It seems to possess the VR pawn but he is stuck in the floor and the Oculus Rift doesn’t show any image. Also I can’t move anything. When I press “V” again, I can go back to the First person pawn and control him just the way it should work.

Is there any other command I need to do to activate the Virtual Reality mode? I’m kind of lost here. -.-

EDIT: I also did a “print string” after the possess node to check, if the Head Mounted Display is Enabled (I just printed the Bool: “Is Head Mounted Display Enabled”). And it always returned false.
Maybe you can’t do this from the level blueprint?

Thks . I’ve tried but i’ve the same results as . Where do you call your event VRStart from? The menu widget “control switch” or the level bp?
Also, you’re not changing maps aren’t you? I mean, you pass through this process once, I assume from your menu widget, then launch the vr start if needed, but all on the same levelmap right?

I also controlled with printstrings that the enable hmd is not doing what we expect him to do and HMD remains not enabled.

What I have gotten to work is the other way around. So I start in VR (with the “VR Preview” Button from the editor) and then possess the First Person Character, then back to the VR Pawn. This seems to work. So it would seem that there is just one component missing that I can do it without starting in VR.

So I just found a partially working solution.
NOTE: It only works in packaged game!

Here is the blueprint: Switch FPS to VR Pawn (working partially) posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4

What works: Go from First Person to VR Pawn.
What doesn’t work: Go back to First Person.

1 Like

All my logic happens in the level blueprint, there is only one level with all 3 pawns already placed. When the escape key is pressed, the “Control Switch” widget, which is just a menu gets added to the viewport and the events like “VRStart” are bound to to the buttons.

I didn’t actually have a VR headset set up when I sent the blueprint to you - I can’t recall if I had to start in VR preview first. If you can’t find any difference between your setup and mine, try packaging the game. Open SteamVR first and ensure the headset is working then run the .exe of your project.

If it doesn’t work then I think I’m at a loss as it could simply be an Oculus Rift issue. (I use a Vive)

You mean in your packaged game you’ve managed to go from a First person view (on screen) to a VR view (in the HMD) ?

Yep, that worked for me. Maybe it has something to do with the Oculus Rift restricting that. I will try to get a hands on a SteamVR headset and try it with that.
I will update you here, when I’ve got something working.

Tried it on packaged version and it worked…that’s great, exactely what I was aiming for!!
I don’t even have to possess the pawn as I am not switching between pawns like you do.

Thks guys!

Nice! Glad you found a solution that works for you.
Just a follow up question: Does it work for you only, when you add both nodes (“Enable HMD” and “Console Command: vr.bEnableStereo 1”)?

Hey there

Okay so I stumbled across this thread as I have been struggling with something similar if not the same. I’m super new to UE4 like 2 months, but diving off the deep end with 10+ years of Archviz work under my belt.

I am trying to create a realtime experience where someone has the option via a main menu to enter into a first person shooter or a VR option if they have a vive or rift. Attached is my main menu screen, which is setup in a main menu level right now. If they click Launch in 1st person I want either a 1st person character pawn to spawn or if they click launch in VR I want a VR pawn to spawn. I have tried setting the cameras(pawns) in a single level to have different player possess numbers, I have tried a different level to each button but am also having no luck.

After I started reading this thread I also wondered if it was because I was just trying to test play it in window which was causing my problem, and if I need to make a deployment to get it to work. The two Pawns I have used in the game are the template based 1st person shooter and the template based VRPawn. I have also attached a screen grab of my menu widget which is how I was trying to control what was launching. I hope one of you can tell me if I am on the right track, completely off track or knows the one thing I may have forgot/gotten wrong.

Thanks

alt text

menu image

tamaginivisuals:
What you’re doing in your blueprint can’t get any results, because you’re only asking for the player controller ID and not setting anything. Eitherway, you can’t change the player controller ID, as far as I know. This is mainly for multiplayer purposes.
Your case should be similar to the one of “DaPhilsh”. Look at his Blueprint: Especially the part labelled “Launch the game”. There he sets all the necessary variables.

If I understand correctly you have two seperate levels. One with the VR Pawn inside and the other with the First Person Pawn. In each of these leves set the Pawn to be auto possessed by Player 0 (which is the standard player). Then you should have control over them. When launching the VR Level, you have to additionally enable the HMD like “DaPhilsh” does in his blueprint.

232275-ue4-autopossesspawn.jpg

Let me know, if I could help you.

Nice graphics by the way. The 10+ years in ArchViz show. :wink:

Just to complete comment, in my case I only manage to make it work on a packaged version. Not working if you only play it on the viewport.

For me too. It only works in the packaged game.
I am using a similar setup to yours now with a main menu at the beginning of the game, where you can choose to launch the game in first person, or in VR mode.

Hey guys thanks for the tips, took me a couple days I had some billable work to do, but I totally have it working now, my two sticking point is I can’t get my touch controllers to work and in VR my pause menu command isnt working. Once I figure that out I will have all the basics to make myself a template. My blueprint is far less complex than the example you shared but it works.