XR Origin component
The purpose of the XR Origin is to transform objects and trackable features to their final position, orientation, and scale in the Unity scene.
XROrigin Component properties
Property | Description | |
Origin Base GameObject | The GameObject whose Transform serves as the origin for trackables or device-relative elements in an XR scene. | |
Camera Floor Offset GameObject | GameObject that offsets the [Camera](xref:UnityEngine.Camera) position from the XR Origin. The XR Origin component controls the Y coordinate of the [Transform](xref:UnityEngine.Transform) of this GameObject according to the chosen Tracking Origin Mode option:
| |
Camera | The Camera for the XR Origin. The GameObject containing this Camera must be underneath the Origin Base GameObject in the Scene hierarchy. It should be a child of the Camera Floor Offset GameObject.
This [Camera](xref:UnityEngine.Camera) is used to render the XR scene. |
|
Tracking Origin Mode | Specifies spatial relationship between the XR Origin and the XR device. | |
Not Specified | Use the default tracking mode of the device (either Device or Floor). | |
Device | In this mode, you manually set the height of the user (for VR) or their hand-held device (for AR) with the **Camera Y Offset** value.
In this mode, the height is not included in the [Poses](xref:UnityEngine.Pose) returned by [XR Input Subsystem](xref:xrsdk-input). At runtime, you must make any needed adjustments manually, which you can do by changing the [XROrigin.CameraYOffset](xref:Unity.XR.CoreUtils.XROrigin.CameraYOffset) property. |
|
Floor | Differs from the Device mode by deriving the height based on the "floor" or other surface determined by the XR device.
In this mode, the height of the user (for VR) or the device (for AR) is included in the [Poses](xref:UnityEngine.Pose) returned by [XR Input Subsystem](xref:xrsdk-input). |
|
Camera Y Offset | The distance to offset the [Camera](xref:UnityEngine.Camera) from the XR Origin when the Device tracking origin mode is active.
Only displayed when either Not Specified or Device is enabled. |
The XROrigin component is designed to work in a specific hierarchy of GameObjects and related components. A typical, recommended setup for an XR Scene includes the following GameObjects and Components:
GameObjects | Components | ||
XR Origin |
| ||
Camera Offset |
| ||
Main Camera |
| ||
LeftHand Controller |
| ||
RightHand Controller |
|
Note
You can have more than one XR Origin in a scene, but only one should be enabled at any given time. For example, if you need different XR Origin configurations in the same scene, you can add them to the scene and choose the one to enable as needed.
Depending on which XR packages you have added to your project, Unity provides a few menu options that add the recommended XR Origin configurations to a scene. You can add the desired configuration to the scene using the GameObject > XR menu. The XR Origin configurations include:
- XR Origin (VR): Adds the XR Origin, Camera Offset GameObject, Camera, and left and right controllers to the scene. Use for Virtual Reality scenes. Included with the XR Interaction Toolkit package.
- XR Origin (AR): Similar to the VR version, but sets the Camera properties appropriately for Mixed and Augmented Reality and adds related AR Camera components. Included with the AR Foundation package (only shown when the XR Interaction Toolkit package is also installed).
- XR Origin (Mobile AR): The same as the AR version, but does not include GameObjects for the controllers. Included with the AR Foundation package.
- Device based > XR Origin (VR): Adds the XR Origin, Camera Offset GameObject, Camera, and left and right controllers to the scene. The controllers in this configuration use device-based input components that map app behaviors directly to the controller buttons and joysticks. Use for Virtual Reality scenes when using the legacy Input Manager. Included with the XR Interaction Toolkit package (not all Interaction Toolkit features are supported when using device-based input).
Tip
You can simply delete the controller GameObjects from the VR or AR configurations if your app doesn't need controllers.
Important
Additional setup is required to configure the left- and right-hand controller objects to process tracking data and user input. See General setup in the XR Interaction Toolkit documentation for more information.