Class TrackedDevice
An input device that has its orientation and position in space tracked.
Inherited Members
Namespace: UnityEngine.InputSystem
Assembly: Unity.InputSystem.dll
Syntax
public class TrackedDevice : InputDevice
Remarks
These values are typically read from input actions and fed into the Tracked Pose Driver component rather than being read directly from this class.
Refer to the Starter Assets sample in the XR Interaction Toolkit package for a Demo Scene with an XR rig hierarchy that uses these concepts.
Properties
devicePosition
Represents the position portion of the input device's primary pose. For an HMD device, this means the "center" eye pose. For XR controllers, it means the "grip" pose.
Declaration
public Vector3Control devicePosition { get; protected set; }
Property Value
| Type | Description |
|---|---|
| Vector3Control |
Remarks
For more information about how OpenXR represents the grip pose, refer to Standard pose identifiers (OpenXR Specification).
Note
The position value is in the tracking space reported by the device, which doesn't match Unity world space. Using a combination of the XR Origin component with the Tracked Pose Driver component to manage that conversion automatically is more reliable than managing it through scripting.
See Also
deviceRotation
Represents the rotation portion of the input device's primary pose. For an HMD device, this means the "center" eye pose. For XR controllers, it means the "grip" pose.
Declaration
public QuaternionControl deviceRotation { get; protected set; }
Property Value
| Type | Description |
|---|---|
| QuaternionControl |
Remarks
For more information about how OpenXR represents the grip pose, refer to Standard pose identifiers (OpenXR Specification).
Note
The rotation value is in the tracking space reported by the device, which doesn't match Unity world space. Using a combination of the XR Origin component with the Tracked Pose Driver component to manage that conversion automatically is more reliable than managing it through scripting.
See Also
isTracked
Indicates whether the input device is actively tracked (1) or not (0).
Declaration
public ButtonControl isTracked { get; protected set; }
Property Value
| Type | Description |
|---|---|
| ButtonControl |
Remarks
For more information about how OpenXR represents inferred position vs. actual position, refer to Reference Spaces (OpenXR Specification).
See Also
trackingState
Indicates which of the tracked pose components are valid by using an integer containing a
bitwise OR of the Unity XR module enum values,
for example InputTrackingState.Position | InputTrackingState.Rotation.
Declaration
public IntegerControl trackingState { get; protected set; }
Property Value
| Type | Description |
|---|---|
| IntegerControl |
Remarks
This property determines whether you can retrieve valid values from the devicePosition and the deviceRotation properties:
- The Position bit must be set for the devicePosition property to have a valid Vector3 value.
- The Rotation bit must be set for the deviceRotation property to have a valid Quaternion.
See Also
Methods
FinishSetup()
Perform final initialization tasks after the control hierarchy has been put into place.
Declaration
protected override void FinishSetup()
Overrides
Remarks
This method can be overridden to perform control- or device-specific setup work. The most common use case is for looking up child controls and storing them in local getters.
Examples
public class MyDevice : InputDevice
{
public ButtonControl button { get; private set; }
public AxisControl axis { get; private set; }
protected override void OnFinishSetup()
{
// Cache controls in getters.
button = GetChildControl("button");
axis = GetChildControl("axis");
}
}