# Contact

![](https://2698598769-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MYpeL-Cll-FXMj9b3XC%2F-MZgFIfY0_IVWMKkuzjz%2F-MZgK8qXjq4rNK_n4jHd%2Fcontact.PNG?alt=media\&token=0140045b-b888-4f4f-8dbd-72a74b393247)

## Introduction

Contact represents the relation between a body part and a contactable object.

Body parts can have multiple bones and sub-parts (e.g. a hand has 1 bone (wrist) and 5 fingers (sub-parts)). Contact stores which **bones under this part (bones of part and its sub-parts)** are touching or are close to touch (entered).

{% hint style="warning" %}
If ContactDetection module is linked to a **hand,** it will handle contacts for all bones in that hand including finger bones.

If ContactDetection module is linked to an **arm,** it will handle contacts for arm's bones, hand bones and finger bones.

If ContactDetection modules is linked to **both arm and hand**, there will be duplicated contacts for hand and finger bones, which is **not recommended**.
{% endhint %}

## Variables

**Name:** Name of the contact. Useful for debugging.

**Detector:** ContactDetection module which is responsible for updating this contact. This ContactDetection module is linked (as child module) to a body part.

**Contactable:** ContactableView that represents the object that is being contacted.

**Special Parts Touching:** How many bones are touching the contactable object and are linked to a part or sub-part that is specially involved in grasping.

{% hint style="info" %}
**Hand, thumb finger and index finger** are the 3 parts that are **specially involved in grasping.**
{% endhint %}

**Type:**

* **None:** 0 bones are entered.
* **Entered:** At least 1 bone is entered. 0 bones are touching touching.
* **Touching:** At least 1 bone is touching. Grasping is not detected.
* **Grasped:** At least 1 bone is touching. Grasping is detected.

{% hint style="info" %}
**Grasping is detected when:**

* There are at least 2 parts touching.
* There are at least 2 parts touching that are specially involved in grasping.
* Not all parts that are touching are parts specially involved in grasping.
  {% endhint %}

**Entered Time:** Elapsed time since at least one bone entered the contactable object.

**Touched Time:** Elapsed time since at least one bone touched the contactable object.

**Grasped Time:** Elapsed time since `Contact.type` became *Grasped*.

**Bones Entered:** List of BoneModels that are near the contactable object.

**Bones Touching:** List of BoneCollisionModels that are touching the contactable object.

{% hint style="info" %}
`ContactDetectionView.contacts` returns a list of **ContactViews**.
{% endhint %}

## BoneCollisionModel

**Bone:** BoneModel which slave representation performed the contact.

**Points:** List of ContactPoints retrieved from the collision detection.

{% hint style="info" %}
`ContactView.bonesTouching` return a list of **BoneCollisionViews**.
{% endhint %}
