VRTK.Documentation

Educational guides and tutorials for learning VRTK.

> Home > How-to Guides > CameraRigs

Adding The UnityXRCameraRig

  • Level: Beginner

  • Reading Time: 2 minutes

  • Checked with: Unity 2018.3.10f1

Introduction

The UnityXR CameraRig prefab provides a camera that tracks the HMD rotation and position along with any available XR controllers.

The outcome of this How-To Guide is to learn how to add the UnityXR CameraRig prefab to the scene and configure it for the tracking space type you require.

Useful definitions

Prerequisites

Let’s Start

Step 1

Expand the VRTK directory in the Unity Project window until the VRTK -> Prefabs -> CameraRig -> UnityXRCameraRig directory is visible and select the UnityXRCameraRig directory so the contents are displayed.

Unity Project Window

Step 2

Select the UnityXRCameraRig prefab then drag and drop it into the Hierarchy window.

Drag UnityXRCameraRig To Hierarchy

Then delete the Main Camera GameObject from the Unity Hierarchy window as the UnityXRCameraRig contains a Main Camera for the Scene.

Step 3

Select the UnityXRCameraRig GameObject in the Unity Hierarchy window and change the Unity XR Configuration component to suit your Tracking Space requirements.

Unity XR Configuration Tracking Space Type

Done

Now you have a UnityXR CameraRig in your scene. If you play the Unity scene you will see that the game Main Camera is tracking the XR HMD and if there is a connected left and/or right XR controller then they will be tracking the Left/Right Anchors of the UnityXR CameraRig.

UnityXRCameraRig In Scene