Humanoid Control for Unity v4
Public Types | Public Member Functions | Public Attributes | Properties | List of all members
Passer.Humanoid.UnityXRTracker Class Reference

Description

Universal API for tracking XR devices.

Setup

Go to Edit Menu->Project Settings->XR Plugin Management and click on the Install XR Plugin Management button:

Then enable the desired XR Plugin. For example the Oculus plugin for Android:

Note that if you want to test Oculus Quest in the editor, the Oculus Plugin for Standalone needs to be enabled too:

Configuration

To enable body tracking with Unity XR for a humanoid, Unity XR needs to be enabled in the HumanoidControl component:

By default the UnityXR object is not visible in the scene, but it will be created automatically when the scene starts. If the button Show is pressed, the UnityXR object will be created in the Real World object.

UnityXR (UnityXR) is a reference to the object in the scene representing the root of the Unit XR tracking space. This GameObject is found as a child of the Real World GameObject. The UnityXR GameObject can be used to adjust the origin of the Unity XR tracking space.

Head %Target

To use an HMD tracking for the head of the avatar Unity XR needs to be enabled on the Head Target too. This is enabled by default:

By default the UnityXRHmd object is not visible in the scene, but it will be created automatically when the scene starts. The UnityXRHmd will also have the main camera attached. You can disable the camera attached to the UnityXRHead object if needed, for example when you want to see the avatar's movements in third person view. If the button Show is pressed, the UnityXRHead object will be created as a child of the UnityXR object in the Real World.

Hand %Target

When you want to control the hands of the avatar using Unity XR you need to enable Unity XR on the Hand Target:

Like with the Head Target, the UnityXRController object is not visible in the editor scene by default but it will be created automatically when the scene starts. If the button Show is pressed, the UnityXRController object will be creates as a child of the UnityXR object in the Real World.

Hand %Tracking (Plus & Pro)

Some devices support hand tracking in combination with UnityXR. Native hand tracking with Unity XR is still not possible, so we provide specific implementations for the following hand tracking options

Oculus Quest

When the Android platform is selected in Unity, an additional option for Oculus Hand Tracking is shown:

When enabled, hand tracking will be possible for this humanoid.

HTC Vive

For Vive hand tracking, the Vive Hand Tracking SDK version 0.9 or higher is required. You can download it here: Vive Hand Tracking SDK. When the HTC Vive Hand Tracking SDK is imported in the project on the Windows Standalone platform, an option for HTC Vive Hand Tracking is shown:

For Vive Hand tracking, the OpenVR Plugin for UnityXR is needed. OpenXR does not work with Vive Hand Tracking in version 1.0.0 of the SDK. This may be fixed in more recent versions. The OpenVR Plugin is automatically installed when the SteamVR Plugin from the Asset Store is imported in the project. HTC Vive headsets like Vive Pre, Vive Pro and normal Vive are supported. HTC Vive Pro 2 is untested, but may work.

Note: if you get an error in the ViveSkeleton.cs code stating that ViveHandTracking is not defined, you need to import the ViveHandTracking/ViveHandTracking.asmdef from the Humanoid Control package.

See also
UnityXRHead UnityXRHand Tracking::UnityXR Tracking::UnityXRHmd Passer::Tracking::UnityXRController
Inheritance diagram for Passer.Humanoid.UnityXRTracker:
Passer.Humanoid.HumanoidTracker Passer.Tracking.Tracker

Public Types

enum  Status { Unavailable , Present , Tracking }
 The tracking status More...
 

Public Member Functions

override void CheckTracker (HumanoidControl humanoid)
 Check the status of the tracker More...
 
override void StartTracker (HumanoidControl humanoid)
 Start the tracker More...
 
override void UpdateTracker ()
 Update the tracker state More...
 
override void Calibrate ()
 Calibrate the tracker More...
 
void CheckTracker (HumanoidControl humanoid, TrackerGetter getTracker)
 Function to check the status of a specific tracker More...
 
void CheckTracker (HumanoidControl humanoid, TrackerGetter getTracker, Vector3 localPosition, Quaternion localRotation)
 Function to check the status of a specific tracker More...
 
delegate TrackerComponent TrackerGetter (Transform transform, Vector3 localPosition, Quaternion localRotation)
 Function delegate for retrieving the tracker More...
 
virtual Vector3 GetBonePosition (uint actorId, FacialBone boneId)
 
virtual Quaternion GetBoneRotation (uint actorId, FacialBone boneId)
 
virtual float GetBoneConfidence (uint actorId, FacialBone boneId)
 
virtual void StartTracker ()
 Optional list of SubTrackers More...
 
virtual void StopTracker ()
 Stop the tracker More...
 
virtual void ShowTracker (bool shown)
 Show or hide the Tracker renderers More...
 
virtual void AdjustTracking (Vector3 positionalDelta, Quaternion rotationalDelta)
 Adjust the position of the tracker by the given delat More...
 

Public Attributes

bool oculusHandTracking = true
 Enables hand tracking on the Oculus Quest
 
bool viveHandTracking = true
 Enables hand tracking on the HTC Vive
 
HumanoidControl humanoid
 The humanoid for this tracker
 
bool enabled
 Is this tracker enabled?
 
Status status
 The tracking Status of the tracker
 
TrackerComponent trackerComponent
 The tracking device
 

Properties

override string name [get]
 The name of this tracker More...
 
override HeadSensor headSensor [get]
 Get the sensor for the head More...
 
override ArmSensor leftHandSensor [get]
 Get the sensor for the left hand More...
 
override ArmSensor rightHandSensor [get]
 Get the sensor for the right hand More...
 
override HumanoidSensor[] sensors [get]
 
virtual TorsoSensor hipsSensor [get]
 Get the sensor for the hips More...
 
virtual LegSensor leftFootSensor [get]
 Get the sensor for the left foot More...
 
virtual LegSensor rightFootSensor [get]
 Get the sensor for the right foot More...
 

Member Enumeration Documentation

◆ Status

The tracking status

Enumerator
Unavailable 

The tracking device is not available.

Present 

The tracking device is available but not tracking.

Tracking 

The tracking device is actively tracking.

Member Function Documentation

◆ CheckTracker() [1/3]

override void Passer.Humanoid.UnityXRTracker.CheckTracker ( HumanoidControl  humanoid)
virtual

Check the status of the tracker

Parameters
humanoidThe humanoid for which the tracker needs to be checked

Reimplemented from Passer.Humanoid.HumanoidTracker.

◆ StartTracker() [1/2]

override void Passer.Humanoid.UnityXRTracker.StartTracker ( HumanoidControl  _humanoid)
virtual

Start the tracker

Reimplemented from Passer.Humanoid.HumanoidTracker.

◆ UpdateTracker()

override void Passer.Humanoid.UnityXRTracker.UpdateTracker ( )
virtual

Update the tracker state

Reimplemented from Passer.Tracking.Tracker.

◆ Calibrate()

override void Passer.Humanoid.UnityXRTracker.Calibrate ( )
virtual

Calibrate the tracker

Reimplemented from Passer.Tracking.Tracker.

◆ CheckTracker() [2/3]

void Passer.Humanoid.HumanoidTracker.CheckTracker ( HumanoidControl  humanoid,
TrackerGetter  getTracker 
)
inherited

Function to check the status of a specific tracker

Parameters
humanoidThe humanoid for which the tracker needs to be checked
getTrackerFunction delegate to retrieve the tracker

The default position/rotation for the tracker when created will be zero

◆ CheckTracker() [3/3]

void Passer.Humanoid.HumanoidTracker.CheckTracker ( HumanoidControl  humanoid,
TrackerGetter  getTracker,
Vector3  localPosition,
Quaternion  localRotation 
)
inherited

Function to check the status of a specific tracker

Parameters
humanoidThe humanoid for which the tracker needs to be checked
getTrackerFunction delegate to retrieve the tracker
localPositionThe default local position of the tracker
localRotationThe default local rotation of the tracker

◆ TrackerGetter()

delegate TrackerComponent Passer.Humanoid.HumanoidTracker.TrackerGetter ( Transform  transform,
Vector3  localPosition,
Quaternion  localRotation 
)
inherited

Function delegate for retrieving the tracker

Parameters
transformThe root transform to start the searching of the tracker
localPositionThe default local position of the tracker
localRotationThe default local rotation of the tracker
Returns
The tracker component found or created

The default position/rotation is relative to the humanoid's real world.

◆ StartTracker() [2/2]

virtual void Passer.Tracking.Tracker.StartTracker ( )
virtualinherited

Optional list of SubTrackers

Start the tracker

◆ StopTracker()

virtual void Passer.Tracking.Tracker.StopTracker ( )
virtualinherited

Stop the tracker

Reimplemented in Passer.Humanoid.LeapTracker.

◆ ShowTracker()

virtual void Passer.Tracking.Tracker.ShowTracker ( bool  shown)
virtualinherited

Show or hide the Tracker renderers

Parameters
shownRenderers are enabled when shown == true

◆ AdjustTracking()

virtual void Passer.Tracking.Tracker.AdjustTracking ( Vector3  positionalDelta,
Quaternion  rotationalDelta 
)
virtualinherited

Adjust the position of the tracker by the given delat

Parameters
positionalDeltaThe positional delta to apply
rotationalDeltaThe rotational delta to apply

Property Documentation

◆ name

override string Passer.Humanoid.UnityXRTracker.name
get

The name of this tracker

◆ headSensor

override HeadSensor Passer.Humanoid.UnityXRTracker.headSensor
get

Get the sensor for the head

Will return null when this sensor is not present

◆ leftHandSensor

override ArmSensor Passer.Humanoid.UnityXRTracker.leftHandSensor
get

Get the sensor for the left hand

Will return null when this sensor is not present

◆ rightHandSensor

override ArmSensor Passer.Humanoid.UnityXRTracker.rightHandSensor
get

Get the sensor for the right hand

Will return null when this sensor is not present

◆ hipsSensor

virtual TorsoSensor Passer.Humanoid.HumanoidTracker.hipsSensor
getinherited

Get the sensor for the hips

Will return null when this sensor is not present

◆ leftFootSensor

virtual LegSensor Passer.Humanoid.HumanoidTracker.leftFootSensor
getinherited

Get the sensor for the left foot

Will return null when this sensor is not present

◆ rightFootSensor

virtual LegSensor Passer.Humanoid.HumanoidTracker.rightFootSensor
getinherited

Get the sensor for the right foot

Will return null when this sensor is not present


The documentation for this class was generated from the following file: