Set Up Cameras for Gear VR

Hero_Image.png

No matter if your Gear VR project is a sitting or standing experience, the manner in which the user's camera is set up will be the same. In the following How  To we will go over how to set up a UE4 camera for use with the Gear VR HMD.

Steps

Below you will find instructions on project setup requirements as well as how to create the needed Pawn Blueprints for Gear VR.

  1. First, create a new UE4 project with the following settings and once the setting has been input, press the Create Project button to create the project.
    • Blueprint
    • Blank Project
    • Mobile / Tablet
    • Scalable 3D or 2D
    • No Starter Content
    • Location for the project to be saved
    • Name for the project
    Click for full image.
  2. Once the project loads, right-click in the Content Browser and from the displayed menu, go to the Create Basic Asset section and select the Blueprint Class option.
    HT_Rift_Camera_Setup_01.png
  3. From the Pick Parent Class window, select the Pawn option and then give it a name of GearVR_Pawn.
    HT_GearVR_Camera_Setup_01.png
  4. Open up the GearVR_Pawn Blueprint and go to the Component section of the Viewport tab. Using the Add Component button add the following two components with the following names making sure that the VRCamera is a child of the VRCameraRoot when completed.
    • Scene - VRCameraRoot
    • Camera - VRCamera
    No matter what VR HMD you are using, this is the Epic recommend way to set up a VR camera as it allows you to offset the position of the camera without having to move the actual camera.
  5. Now open up the GearVR_Pawn Blueprint and in the Event Graph drag off the Event Begin Play node to show the Executable actions list and search for the Set Tracking Origin node, clicking on it to add it to the Event Graph.
    HT_Rift_Camera_Setup_09.png
  6. Make sure the Origin of the Set Tracking Origin node is set to Eye Level.
    HT_Rift_Camera_Setup_10.png
  7. In the Blueprint Editor under the Variables section, create a new Vector variable called Camera Height and set the Z value to 180.
    This number set in CameraHeight should be set to the real world standing height of the user in Centimeters.
  8. Drag off the output of the Set Tracking Origin node and search for the Set Relative Location node, selecting the SetRelativeLocation(VRCameraRoot) option.
    HT_GearVR_Camera_Setup_04.png
  9. Connect the CameraHeight variable to the New Location input on the Set Relative Location node and then press the Compile button. When completed your Event Graph should look like the following image.
    Copy Node Graph
    You can copy the completed Blueprint by clicking on the upper left-hand corner of above and pressing CRTL + C to copy the graph. Once copied, go to your Blueprints event and press CTRL + V to paste it in.
  10. Drag the GearVR_Pawn  Blueprint from the Content Browser to a level, making sure that it is placed as close to the ground as possible.
    Click for full image.
  11. Select the GearVR_Pawn Blueprint and in the Details panel under the Pawn setting, set the Auto Possess Player from Disabled to Player 0.
    HT_GearVR_Camera_Setup_07.png
  12. Finally, go to the Main Toolbar and click on the small white triangle next to Launch Options and then select your Android device from the list to start the packaging and deployment to that device.

End Result

Once the UE4 project has deployed, put your Smartphone into your Gear VR HMD and when you move your head around it should look like the following video.

UE4 Project Downloads

Below you will find a link to where you can download the UE4 project that was used to create this example.