Unity AR's motion tracking center —— XR Origin
XR Origin is the core concept of motion tracking functionality in Unity. In modern AR applications, motion tracking is gradually becoming an essential feature. Through motion tracking, applications can understand the user's position and orientation in the real world without relying on other markers, enabling an immersive AR experience. The following content will introduce the basic concepts, components, and lifecycle of XR Origin, as well as the scenarios in which XR Origin is required.
Before you begin
- Learn the basic concepts, components, and workflow of a session through Introduction to ARSession.
What is XR Origin
When motion tracking is initialized, a reference point is selected as the origin of tracking. This reference point is usually the position of the device when the application is launched or when the system AR service starts. The representation of this reference point in the Unity scene is the XR Origin. In most cases, the starting position of the XR Origin in the scene is also the default starting position of the camera.
This video shows a simple AR scene with only motion tracking running. On the left is the
Hierarchyview, in the middle is theSceneview, and on the right is theGameview. The video was recorded in the Unity editor'sPlaymode using simulated runtime data. The content in theGameview is the same as what a user would see in the real world on their mobile device.As seen in the video, the XR Origin (blue sphere) remains fixed in the scene, while the camera representing the user (camera icon) moves according to the user's movement in the real world. The white cones capture the trajectory of the camera's position and orientation over a period of time, providing a better understanding of the camera's movement in the scene. These white cones are generated under the XR Origin's node, which is a typical organizational structure for objects in such scenes.
In Unity's motion tracking system, the camera generally follows the XR Origin for movement. Although the camera is not necessarily a child node of the XR Origin, the AR Session calculates the camera's position based on the XR Origin's position to ensure that what the user sees aligns with the real world.
This video shows the same scene, but this time we moved the XR Origin (blue sphere) during runtime. It can be observed that after the XR Origin is moved, the camera follows the XR Origin's movement, while the content in the
Gameview remains unchanged.
In actual AR scenes, this motion relationship is more complex.
Behavior of XR Origin in Different Center Modes
In Unity, the central reference point for all AR tracking is called the session center, and the rule that determines this center during the session is called the center mode. The behavior of XR Origin varies under different center modes:
In the SessionOrigin center mode, the XR Origin can be moved freely.
Generally, the SessionOrigin mode is used in scenarios where only motion tracking is active. When other features are running simultaneously, the SessionOrigin mode is usually not used.
However, when using a headset, if the manufacturer does not correctly implement the reference point for motion tracking in Unity, it becomes necessary to use Unity's world center, thereby forcing the use of the SessionOrigin mode. This situation requires the root node of the content to follow the movement of the AR feature, which may affect the content's performance, but there is no alternative until third-party manufacturers make changes.
In other center modes (such as FirstTarget), the XR Origin cannot be moved freely.
The FirstTarget mode is generally used in scenarios where non-motion tracking or other AR features are running simultaneously with motion tracking.
In this mode, the position of the XR Origin is determined by the AR feature, so the XR Origin cannot be moved arbitrarily.
For details about center modes and the movement of objects in the scene, refer to: Center Mode.
XR origin form and composition
EasyAR can use two different forms of XR Origin:
- XR Origin provided by EasyAR
- XR Origin provided by Unity XR framework
XR Origin (EasyAR)
A typical XR Origin structure is as follows:

The root node of the XR Origin is an empty GameObject, which can have one or more XR Origin Child nodes. The XR Origin Child contains a XROriginChildController component, which acts as a proxy for the XR Origin's control logic.
During the session runtime, if there is no correct XR Origin structure in the scene, an XR Origin and an XR Origin Child will be automatically created. During runtime, the XR Origin Child will be constrained to the same position and orientation as the XR Origin.
Objects generated by the session, such as point clouds from sparse spatial mapping or meshes from dense spatial mapping, will be created under the XR Origin Child node.
This video demonstrates the effect of running dense spatial mapping while performing motion tracking in the same scene. It can be observed that the generated mesh is created under the XR Origin Child node.
Note: For clarity, depth map generation is turned off in the video, so the content in the
Sceneview may differ from what is displayed during actual runtime. The display effect in theGameview is the same as when mesh transparency is turned off.
[Optional] XR Origin (Unity XR)
If needed, you can choose to use the XR Origin component provided by the Unity XR framework.
When using the XR Origin provided by the Unity XR framework, a typical structure is as follows:

In a headset scenario, a typical structure is as follows:

The XR Origin root node is a GameObject created and maintained by the Unity XR framework. It can have one or more XR Origin Child nodes. An XR Origin Child contains a XROriginChildController component, which proxies the control logic of the XR Origin.
During session runtime, if there is no correct XR Origin Child structure in the scene, the XR Origin Child will be automatically created. During runtime, the XR Origin Child will be constrained to the same position and orientation as the XR Origin.
The XR Origin provided by the Unity XR framework primarily supports the following two scenarios:
- You are already using AR Foundation in your project and want it to work alongside EasyAR or switch between them based on device support.
- The headset SDK you are using employs the XR Origin component provided by the Unity XR framework.
Note
When the core package of Unity XR, com.unity.xr.core-utils, is not imported into the project, if the camera in the scene is in the same hierarchical structure as the XR Origin provided by the Unity XR framework (a Camera and a parent node named Camera Offset), the session will assume this structure was created by the Unity XR framework and use it. This is done to provide maximum compatibility for the scene, meaning that scenes created with AR Foundation will still function normally (excluding features only provided by AR Foundation) even when AR Foundation is not imported into the project. This does not affect the overall AR functionality or device compatibility, except for features exclusive to AR Foundation.
Most of EasyAR's sample scenes use this approach to ensure they can run without AR Foundation while also demonstrating the ability to work alongside AR Foundation when it is present.
In AR Foundation's definition, its XR Origin is the center of the tracked space in an XR scene. However, it is important to note that in AR Foundation's concept, motion tracking is treated as a mandatory feature, and the tracking it describes in an XR scene refers to motion tracking.
In the EasyAR system, motion tracking is an optional feature, so the XR Origin is also optional. The XR Origin is only created and used when motion tracking is enabled.
Lifecycle of the XR origin
The lifecycle of the XR origin depends on the session. When the session starts, the XR origin is selected or created (if there is no correct XR origin structure in the scene). When the session stops, the XR origin remains in place until it is used by the next session or manually deleted.
Next steps
Create
- Try to create an XR Origin in the scene
Control runtime
- Learn about the Active control strategy of XR Origin