So I finally got a chance to play around with the Oculus Rift for a bit, needless to say I used that time to make a VR port for FPS Game Starter Kit!
On this page I’ll post all of my notes and various screenshots of what I did in order to get it to work and what to consider when working with VR etc.
So let’s begin..
1. Connect it and install its software
2. Once it’s installed follow the on screen instructions to set it up, the main part is to have all of these lights green, because otherwise it will let you run some of the software from it, but UE4 will NOT detect it. So make sure it’s all good
Moving on to FPS Game Starter kit now
3. Open Project Settings, and under Input add your devices and which key they should use. The one I worked with was “Oculus Rift”, and not the “Go” version or others, but the following configuration worked for me. I added them in the gamepad ones because of keybinding for mouse and keyboard, so that it doesn’t create a conflict there.
4. One would think that it takes a lot of reworking to get the character ready, but actually no, it’s super easy, barely an inconvenience!
Just create a child class based on BP_CharacterBase and set it as the new default pawn in the game mode
5. Once that is done, open your new VR character child class and add few components to it. Add 2 new motion controllers for L and R hands and set them on the details panel. On the Right one add a skeletal mesh (dont select any yet) and a springarm (0 distance and no collision)
6. Once that is done, create a new function and connect it to an event tick.
If the character appears to be too low to the ground, please stand up XD the sensor was calibrated while standing, so it moves the camera down when you sit.
Also camera related, in the new VR character child class in its FirstPersonCamera component you can enable/disable Use Pawn Control Rotation, this will affect the right analog joystick movement to left/right.
For the Left Motion Controller, because it’s technically blank in the example, you can use it for other things like doing a linetrace and teleport to some location like other VR games have it.
7. It’s already possible to use it, but I wanted to bring it one step further, and that’s to make the weapon fire where it’s being pointed at, not where the eyes are looking. In VR these are two different things, so in the BP_WeaponBase create 2 new variables (bool and vector, default values are false and 0,0,0)
While there, locate the projectile spawn logic and double click to open it..
8. In the projectile spawn add the following:
9. Now there is a new checkbox on all weapon child classes if it should use VR, to make it work enable it on your VR weapons. Also, add this to your weapon child classes!
NOTE: You can also use this as the VR weapon base, so that you can create child classes from it or simply create a duplicate.