Class TrackedPoseDriver
The TrackedPoseDriver component applies the current Pose value of a tracked device to the transform of the GameObject. TrackedPoseDriver can track multiple types of devices including XR HMDs, controllers, and remotes.
Inherited Members
Namespace: UnityEngine.SpatialTracking
Assembly: UnityEngine.SpatialTracking.dll
Syntax
[DefaultExecutionOrder(-30000)]
[Serializable]
[AddComponentMenu("XR/Tracked Pose Driver")]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.legacyinputhelpers@2.1/manual/index.html")]
public class TrackedPoseDriver : MonoBehaviour
Fields
m_OriginPose
The origin pose is the offset applied to any tracking data. This is only used when in legacy compatibility mode.
Declaration
protected Pose m_OriginPose
Field Value
Type | Description |
---|---|
Pose |
Properties
UseRelativeTransform
This is used to indicate whether the TrackedPoseDriver will use the object's original transform as its basis.
Declaration
public bool UseRelativeTransform { get; set; }
Property Value
Type | Description |
---|---|
bool |
deviceType
This is used to indicate which pose the TrackedPoseDriver is currently tracking.
Declaration
public TrackedPoseDriver.DeviceType deviceType { get; }
Property Value
Type | Description |
---|---|
TrackedPoseDriver.DeviceType |
originPose
originPose is an offset applied to any tracking data read from this object. Setting this value should be reserved for dealing with edge-cases, such as achieving parity between room-scale (floor centered) and stationary (head centered) tracking - without having to alter the transform hierarchy. For user locomotion and gameplay purposes you are usually better off just moving the parent transform of this object.
Declaration
public Pose originPose { get; set; }
Property Value
Type | Description |
---|---|
Pose |
poseProviderComponent
Optional: This field holds the reference to the BasePoseProvider instance that, if set, will be used to override the behavior of the TrackedPoseDriver. When this field is empty, the TrackedPoseDriver will operate as per usual, with pose data being retrieved from the device or pose settings of the TrackedPoseDriver. When this field is set, the pose data will be provided by the attached BasePoseProvider. The device or pose fields will be hidden as they are no longer used to control the parent GameObject Transform.
Declaration
public BasePoseProvider poseProviderComponent { get; set; }
Property Value
Type | Description |
---|---|
BasePoseProvider |
poseSource
The pose being tracked by the tracked pose driver
Declaration
public TrackedPoseDriver.TrackedPose poseSource { get; }
Property Value
Type | Description |
---|---|
TrackedPoseDriver.TrackedPose |
trackingType
The tracking type being used by the tracked pose driver
Declaration
public TrackedPoseDriver.TrackingType trackingType { get; set; }
Property Value
Type | Description |
---|---|
TrackedPoseDriver.TrackingType |
updateType
The update type being used by the tracked pose driver
Declaration
public TrackedPoseDriver.UpdateType updateType { get; set; }
Property Value
Type | Description |
---|---|
TrackedPoseDriver.UpdateType |
Methods
Awake()
Refer to MonoBehaviour.
Declaration
protected virtual void Awake()
FixedUpdate()
Refer to MonoBehaviour.
Declaration
protected virtual void FixedUpdate()
OnBeforeRender()
Refer to Application.
For the same reason as DefaultExecutionOrder, a callback order is specified to apply the pose to the Transform before default user scripts execute.
Declaration
[BeforeRenderOrder(-30000)]
protected virtual void OnBeforeRender()
OnDestroy()
Refer to MonoBehaviour.
Declaration
protected virtual void OnDestroy()
OnDisable()
Refer to MonoBehaviour.
Declaration
protected virtual void OnDisable()
OnEnable()
Refer to MonoBehaviour.
Declaration
protected virtual void OnEnable()
PerformUpdate()
PerformUpdate queries the data from the selected pose source, and then calls SetLocalTransform(Vector3, Quaternion, PoseDataFlags) to apply the pose.
Declaration
protected virtual void PerformUpdate()
SetLocalTransform(Vector3, Quaternion, PoseDataFlags)
Sets the transform that is being driven by the TrackedPoseDriver. will only correct set the rotation or position depending on the PoseDataFlags
Declaration
protected virtual void SetLocalTransform(Vector3 newPosition, Quaternion newRotation, PoseDataFlags poseFlags)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | newPosition | The position to apply. |
Quaternion | newRotation | The rotation to apply. |
PoseDataFlags | poseFlags | The flags indiciating which of the position/rotation values are provided by the calling code. |
SetPoseSource(DeviceType, TrackedPose)
This method is used to set the device / pose pair for the SpatialTracking.TrackedPoseDriver. setting an invalid combination of these values will return false.
Declaration
public bool SetPoseSource(TrackedPoseDriver.DeviceType deviceType, TrackedPoseDriver.TrackedPose pose)
Parameters
Type | Name | Description |
---|---|---|
TrackedPoseDriver.DeviceType | deviceType | The device type that we wish to track |
TrackedPoseDriver.TrackedPose | pose | The pose source that we wish to track |
Returns
Type | Description |
---|---|
bool | true if the values provided are sensible, otherwise false |
TransformPoseByOriginIfNeeded(Pose)
This is only used when running in legacy mode, and will fake the behavior of the old implicit camera tracking. This will transform by the origin pose if necessary.
Declaration
protected Pose TransformPoseByOriginIfNeeded(Pose pose)
Parameters
Type | Name | Description |
---|---|---|
Pose | pose | Pose to transform by the origin if in relative transform mode. |
Returns
Type | Description |
---|---|
Pose | The pose, with the applied transform if in Relative Transform mode. |
Update()
Refer to MonoBehaviour.
Declaration
protected virtual void Update()