# MRTK

MRTK works great for UI and remote interactions. You can get the best of physically contrained UI and remote interaction with by using MRTK+HPTK.

However, MRTK has some particularities that you have to know in order to make it work properly:

* MRTK uses **Standard rendering pipeline**. HPTK comes out-of-the-box to use URP.
* MRTK uses **collision layers** to detect ray targets that may interfere with our collider-full hands.
* MRTK **instantiates the rig on run-time** according to the platform but HPTK singleton needs references to the camera and the tracking space origin.

## How to use MRTK + HPTK?

{% hint style="info" %}
**For new scenes,** add the **DefaultSetup** prefab that fits your target platform. If the scene does not contain any avatar, add the **DefaultAvatar** prefab that fits your render pipeline.&#x20;

**More details** about initial setup in [Setup](/hptk/master/setup.md) section.
{% endhint %}

### 1. Obtain MRTK

**MRTK +2.5** can be managed using the **Unity Package Manager (UPM)**. Follow this [documentation](https://docs.microsoft.com/es-es/windows/mixed-reality/mrtk-unity/configuration/usingupm) to install Mixed Reality features using the UPM.

If you're new to MRTK or Mixed Reality development in Unity, take a look to this [guide](https://docs.microsoft.com/en-us/windows/mixed-reality/develop/unity/unity-development-overview?tabs=mrtk%2Carr%2Chl2). This guide is the recommended starting point for MRTK, specifically created to walk you through the installation, core concepts, and usage of MRTK in Unity.

For educational purposes, [MRTK-Quest-Sample](https://github.com/provencher/MRTK-Quest-Sample) is a ready-to-go Unity project made by [provencher](https://github.com/provencher) that uses MRTK and Oculus Quest hand tracking.

### 2. Configure MRTK

Add **MicrosoftRealityToolkit** singleton to your scene.

Open the **MRTK Project Configurator** window (Mixed Reality Toolkit > Utilities > Configure Unity Project). Then **apply the recommended configuration**.

![](/files/-MZ0FNpKb3TZb5lISf4i)

#### 2.1. Integrate Oculus-MRTK (Quest)

From Unity Package Manager, install the **Oculus XR Plugin** package.

**Integrate** Oculus Integration Unity modules from *Mixed Reality Toolkit > Utilities > Oculus > Integrate Oculus Integration Unity Modules*.

![](/files/-MZ0HKQAPPtKjBAn34Q2)

### 3. Collision layers

Configure **layer collision matrix** in ProjectSettings/Physic&#x73;**:**

1. Create new layer called ***HPTK***.
2. Make ***HPTK*** layer to **ignore&#x20;*****Default*****&#x20;and&#x20;*****UI*****&#x20;layers**.

![](/files/-MZ0aLtfaN4Qj2C3vAgK)

**Use the new collision layer.** In HPTK singleton, set `HPTK.applyThisLayerToChildren = HPTK`

On Start, HPTK will apply that layer to all its children as HPTK singleton is the root object that encapsulates the GameObjects related with HPTK, including the avatar representations.

### 4. Switch to StandardRP

If you are using the **DefaultAvatar.URP** prefab, replace it by the **DefaultAvatar.Standard** prefab variant.

{% hint style="info" %}
If DefaultAvatar.URP is part of another prefab, **unpack** its parent prefab first.
{% endhint %}

### 5. Remove references to camera and tracking spaces (Quest)

**Remove** any existing instance of **OVRCameraRig** as MRTK will instantiate it on start.

In the **HPTK singleton** set:

* `HPTK.trackedCamera = NULL`
* `HPTK.trackingSpace = NULL`

For each **OVRSkeletonTracker** set:

* `OVRSkeletonTracker.ovrHand = NULL`
* `OVRSkeletonTracker.ovrSkeleton = NULL`

When these values are missing, **each OVRSkeletonTracker will search for those values** each frame until finding them. They will find it once MRTK instantiates the OVRCameraRig.

### 6. Import HPTK+MRTK Integration Package

Open the **Integration Manager,** click on **MRTK** and import the built-in integration package.

![](/files/-MZbEtUziL4LX3zjE9jQ)

### 7. Import MRTK-Quest Integration Package (Quest)

Open the **Integration Manager,** click on '**MRTK Quest'** and import the built-in integration package.

This package contains a **demo scene** with MRTK+HPTK working for Oculus Quest.

MRTK Quest integration package has **dependencies with the Oculus integration package**. If Oculus integration package is not imported in your project, then open Integration Manager, click on Oculus and import the package.

### 8. Set the configuration profile

In the Mixed Reality Toolkit singleton, set the profile **MRTK-HPTK-ConfigurationProfile**.

![](/files/-MZ0JCzhb3tIvNdwZQRr)

### 9. Add an interactive object

In `Assets/HPTK/Integrations/MRTK/Prefabs/Interactables` you will find some **example objects.**

These objects exemplify how MRTK remote interactions can be combined with touchable objects and physics-based near interactions.

These objects follow a **pattern**:

* **Root object:**
  * Uses the **Default layer.**
  * The MRTK-related components are attached to it.
  * Has a BoxCollider component that defines its boundaries.
* **Child object:**
  * Uses the **HPTK layer** (and its child objects).
  * Contains the Colliders that defines the touchable surface.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jorge-jgnz94.gitbook.io/hptk/master/integrations/mrtk.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
