VR Camera Refactor


With the release of Unreal Engine 4.11 Virtual Reality(VR) cameras now work a bit different than in previous versions of UE4. The biggest change is that objects will now follow the camera simply by making the camera the objects parent. This also means that you will no longer be required to offset tracking objects by the Head Mounted Display(HMD) transform. Components attached to the Camera Actor will now keep their position relative to the camera, making it easy to add a helmet, collision, or other primitives to the player. The attached renderable components will now also receive the same late update transforms used in low-latency rendering to keep them perfectly in-sync with HMD motion. In the following document, we will go over all you need to know about how these changes will affect your past that are upgraded as well as the effects on future UE4 projects.

VR Camera Setup in UE 4.11 and Later

Make sure to note that the Camera Manager no longer dictates when a camera should track the HMD, that is all set directly on the camera itself through the Lock to HMD option.

If you are creating a new VR project using UE 4.11 or later, the camera will already be setup to be in sync with the HMD as this functionality is now enabled by default. However if you wish to disable this all you will need to do is select the Camera in your Player Blueprint and then in the Details panel under the Camera section uncheck the Lock to HMD option which you can see highlighted in the image below.


Upgrading Previous VR Cameras to 4.11

If you are upgrading your UE4's project from a previous release to the 4.11 release there are a few things you will need to do to ensure that your previous VR camera setup will work with the new 4.11 changes. Depending on how your Camera is created and setup you will need to ensure that either of the following changes are made in order to get your VR camera working correctly.

Base Camera Component

In the case of a bare Camera Component, the camera transform is the HMD offset and a "base" will be required to move the player's head through a scene. If you see your VR camera on the ground after migrating to 4.11 you will need to insert a new scene transform to set the placement of the camera base as detailed in the image below.


Camera Actor Component

In the case of a Camera Actor, a base scene transform automatically gets inserted as a parent to the actor's own Camera Component giving it a complete transform chain as detailed in the image below.


Now if you want to get the position of the player in the world you can just get the Camera Actor's position.

Setting up objects to follow the HMD

Setting up 3D Mesh, Particle Effects, or UI elements so that they can follow the movement of the HMD can be accomplished in the following few steps.

  1. First open up your Character Blueprint and then navigate to the Viewport tab of the Blueprint Editor.


  2. Next from the Component tab, click on the Add Component option and then input the word Cube into the search box then click on the Cube mesh that is displayed to add it as a component


  3. With the Cube Static Mesh now added, select the Cube Static Mesh and then drag it onto the camera so that camera is now the parent of them mesh.


  4. Now compile your Blueprint and then launch your project using the VR preview option from inside the UE4 editor. When you put an HMD on then move your head around the Cube you attached will now accurately follow your head movements like in the video below.

HMD and Player Position

One of the other advantages the new camera refactor gives you is the ability to quickly get the world location of the camera / HMD by getting the location of the Camera Component. In the image below you can see an example of this in action.


In the above image whenever a user presses the T key on the keyboard the X, Y and Z position of the Camera in the world will then be output to the screen and log window.