# Contact Detection

![](/files/-MZgJ95SnD3Xp2bKuzlu)

## Model

ContactDetection module keeps track of contacts between hand's slave representation and contactable Rigidbodies (ContactableViews). It can distinguish hovering, touching and friction-based grabbing. This module requires a Puppet module to be registered in the same part. Variables of this model are described bellow:

#### References

* **Part:** The part whose slave representation will be subject to contact detectio&#x6E;**.** This reference has to be manually set.

#### Control

* **Hover DetectionSystem:** How should hovering be detected?
  * **Overlap Sphere From Root:** ContactableViews inside a sphere with center `ContactDetectionModel.part.root.point.reprs["slave"].transformRef.position` and radius `ContactDetectionModel.sphereCastRadius` will be considered as entered (hovered).
  * **Triggers:** TriggerNotifiers form Pheasy component of slave representation of part's root bone will be used to detect entered (hovered) objects.
* **Sphere Cast Radius:** If using sphere overlap as hover detection system, this value will represent the radius of that sphere.<br>
* **Detect Only These:** If enabled, the list `ContactDetectionModel.bonesToDetect` won't be automatically populated and the existing bones in this list will be the only ones that will be subjected to contact detection.
* **Bones To Detect:** List of bones subjected to contact detection.

#### State

* **Is Entered:** Is some bone hovering some contactable object?
* **Is Touched:** Is some bone touching some contactable object?
* **Is Grasped:** Is the part grasping some contactable object?&#x20;
* **Contacts:** List of detected contacts. Contacts are described in detail [here](/hptk/master/modules/contact-detection/contact.md).

{% hint style="info" %}
**Grasping detection** is only appliable when references part is a **hand (HandModel)**.
{% endhint %}

![](/files/-MZgJB2vmfaFuWi2HH7F)

## View

#### Events

* **OnFirstEnter:** Emmitted when a bone starts hovering an object while the rest of the bones are not contacting (hovering, touching or grasping) any object.
* **OnEnter:** Emitted when a bone starts hovering some contactable object.<br>
* **OnFirstTouch:** Emmitted when a bone starts touching an object while the rest of the bones are not touching or grasping any object.
* **OnTouch:** Emitted when a bone starts touching some contactable object.<br>
* **OnFirstGrasp:** Emmitted when a bone starts grasping an object while the rest of the bones are not touching or grasping any object.
* **OnGrasp:** Emitted when a bone starts grasping some contactable object.<br>
* **OnUngrasp:** Emitted when a bone stops grasping some contactable object.
* **OnLastUngrasp:** Emmitted when the last bone grasping an object stops doing it.<br>
* **OnUntouch:** Emitted when a bone stops touching some contactable object.
* **OnLastUntouch:** Emmitted when the last bone touching an object stops doing it.<br>
* **OnExit:** Emitted when a bone stops hovering some contactable object.
* **OnLastExit:** Emmitted when the last bone hovering an object stops doing it.


---

# 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/modules/contact-detection.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.
