Singleton

The core of HPTK

The Singleton

HPTK requires an instance of the HPTK component which will be publicly accessible from the static variable HPTK.core.

The following code exemplifies how to access this singleton in order to retrieve the AvatarView of the first registered avatar:

AvatarView avatar = HPTK.core.avatars[0];

You have more code examples here.

Variables

Tracked Camera

Represents the Transform in your scene that will always match user's sight.

This is manually provided as it's a platform-dependent variable. According to you platform this Transform will be found in the following GameObjects:

  • OVR: OVRCameraRig > TrackingSpace > CenterEyeAnchor

  • UnityXR: XRRig > Camera Offset > Main Camera

If you use DefaultSetup prefabs this value is already set.

If BodyModel.masterHeadFollowsCamera is enabled, the master representation of BodyModel.head will be moved to match HPTK.core.trackedCamera. This application will be straight forward if BodyModel.referenceTsf or BodyModel.replicatedTsf are NULL, and it will be relative otherwise.

TrackingSpace

Represents the Transform in your scene that will always match user's feet (floor).

If tracking space origin will be at floor level (by default), this variable should refer to tracking space origin.

If tracking space origin will be at eye level, this variable should refer to some Transform that always stays under camera at floor level. This can be achieved through a custom Transform with a Position Contraint configured as show in the following image.

Default Conf Assets

Some HPTK modules require a configuration asset (ScriptableObject). If this reference is missing, the Controller of the module will access HPTK.core.defaultConfAssets and wil search in this list for a configuration asset that matches the required type.

Controls Update Calls

If enabled, HPTK singleton will call, each frame, AvatarController.ControllerUpdate() for each registered avatar in the order of registration. Each AvatarController.ControllerUpdate() call will update each module registered in the avatar or any of its bodies or parts, always in order of registration. This is useful if we are using some order-sensitive custom module but this is not the case for any module included in the HPTK package or any of its current extensions.

If disabled (recommended), each HPTKController will be updated by itself by calling its ControllerUpdate() method during its Update() method.

Input Data Providers

Similarly to Default Conf Assets, these Input Data Providers (IDPs) will be accessed by Input modules that have no IDP already referenced.

If you are in PlayMode, editor IDPs will be used. If you are in build, build IDPs will be used.

This way if you can press Play in UnityEditor, a simulation of your player's movements will be played for debugging quicker. Without any extra change, if you build and play your app in your device, "build" IDPs will take control.

If you need to use build IDPs in editor for instance to use hand tracking in Unity through Oculus Link, just replace their references in the singleton.

Layer to apply

When an avatar is self-registered in the singleton's list of avatars, this layer (layer "HPTK" by default) is applied to each representations of the root bone of each of the bodies of the avatar and its children gameobjects as well, recursively.

Events

  • OnAvatarEntered: An avatar was registered and the ControllerStart() function of its Controller was called and completed.

  • OnAvatarExited: An avatar is about to be removed from HPTK.core.avatars.

Last updated