Humanoid Control for Unity v4
|
Universal API for tracking XR devices.
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:
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.
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.
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.
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
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.
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.
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. | |
override void | StartTracker (HumanoidControl humanoid) |
Start the tracker. | |
override void | UpdateTracker () |
Update the tracker state. | |
override void | Calibrate () |
Calibrate the tracker. | |
void | CheckTracker (HumanoidControl humanoid, TrackerGetter getTracker) |
Function to check the status of a specific tracker. | |
void | CheckTracker (HumanoidControl humanoid, TrackerGetter getTracker, Vector3 localPosition, Quaternion localRotation) |
Function to check the status of a specific tracker. | |
delegate TrackerComponent | TrackerGetter (Transform transform, Vector3 localPosition, Quaternion localRotation) |
Function delegate for retrieving the tracker. | |
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. | |
virtual void | StopTracker () |
Stop the tracker. | |
virtual void | ShowTracker (bool shown) |
Show or hide the Tracker renderers. | |
virtual void | AdjustTracking (Vector3 positionalDelta, Quaternion rotationalDelta) |
Adjust the position of the tracker by the given delat. | |
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] |
override HeadSensor | headSensor [get] |
override ArmSensor | leftHandSensor [get] |
override ArmSensor | rightHandSensor [get] |
override HumanoidSensor[] | sensors [get] |
virtual TorsoSensor | hipsSensor [get] |
Get the sensor for the hips. | |
virtual LegSensor | leftFootSensor [get] |
Get the sensor for the left foot. | |
virtual LegSensor | rightFootSensor [get] |
Get the sensor for the right foot. | |
|
inherited |
|
virtual |
Check the status of the tracker.
humanoid | The humanoid for which the tracker needs to be checked |
Reimplemented from Passer.Humanoid.HumanoidTracker.
|
virtual |
Start the tracker.
Reimplemented from Passer.Humanoid.HumanoidTracker.
|
virtual |
Update the tracker state.
Reimplemented from Passer.Tracking.Tracker.
|
virtual |
Calibrate the tracker.
Reimplemented from Passer.Tracking.Tracker.
|
inherited |
Function to check the status of a specific tracker.
humanoid | The humanoid for which the tracker needs to be checked |
getTracker | Function delegate to retrieve the tracker |
The default position/rotation for the tracker when created will be zero
|
inherited |
Function to check the status of a specific tracker.
humanoid | The humanoid for which the tracker needs to be checked |
getTracker | Function delegate to retrieve the tracker |
localPosition | The default local position of the tracker |
localRotation | The default local rotation of the tracker |
|
inherited |
Function delegate for retrieving the tracker.
transform | The root transform to start the searching of the tracker |
localPosition | The default local position of the tracker |
localRotation | The default local rotation of the tracker |
The default position/rotation is relative to the humanoid's real world.
|
virtualinherited |
Optional list of SubTrackers.
Start the tracker
|
virtualinherited |
Stop the tracker.
Reimplemented in Passer.Humanoid.LeapTracker.
|
virtualinherited |
Show or hide the Tracker renderers.
shown | Renderers are enabled when shown == true |
|
virtualinherited |
Adjust the position of the tracker by the given delat.
positionalDelta | The positional delta to apply |
rotationalDelta | The rotational delta to apply |
|
get |
|
get |
|
get |
|
get |
|
getinherited |
Get the sensor for the hips.
Will return null when this sensor is not present
|
getinherited |
Get the sensor for the left foot.
Will return null when this sensor is not present
|
getinherited |
Get the sensor for the right foot.
Will return null when this sensor is not present