> ## Documentation Index
> Fetch the complete documentation index at: https://docs-unity.molca.id/llms.txt
> Use this file to discover all available pages before exploring further.

# MolcaInteractionBase

> Shared VR interaction behavior for XRI grab and analog controls.

**File:** `Assets/_MolcaSDK/_VR/Scripts/Base/MolcaInteractionBase.cs`

## When to use

Use this when building VR training content that needs Molca Interaction Base functionality.

## Role

* Discovers **`XRGrabInteractable`**
* Tracks **which interactor** is active
* **Lock / unlock** interaction
* Implements analog interaction contracts used by valve/knob flows

Concrete types: [Valve interaction](/vr/interactions/valve-interaction), [Knob interaction](/vr/interactions/knob-interaction), plus additional scripts under `Interactions/`.

## Code

Derive from **`MolcaInteractionBase`**, let **`Awake`** auto-pick **`XRBaseInteractable`** on the same object (or assign **`interactable`** in the Inspector), and implement **`UpdateInteraction()`** for per-frame behavior while the user is interacting. The base registers with **`ReferenceManager`** after **`RuntimeManager`** is ready.

```csharp theme={null}
using MolcaSDK.VR;
using UnityEngine;

public class CustomLeverInteraction : MolcaInteractionBase
{
    protected override void UpdateInteraction()
    {
        // Per-frame while isInteracting — drive rotation, haptics, step completion, etc.
    }
}
```

Compare with **`ValveInteraction`** / **`KnobInteraction`** for analog value plumbing.

## Troubleshooting

* **Interactable null** — Assign **`interactable`** or rely on **`Awake`** (same **`GameObject`** only — no child search).
* **Reference / SceneObjectReference not found** — **`ReferenceManager.Register`** runs after **`WaitForInitialization`**; ensure **`ReferenceManager`** exists and **`refId`** is stable (**`OnValidate`** generates ids).
* **Unexpected drops** — **`maxInteractionDistance`** > 0 forces **`ForceRelease`** when hand is too far; set **0** to disable.
* **`UpdateInteraction` not running** — Only called while **`isInteracting`**; verify XRI **`selectEntered`** / **`selectExited`** wiring on **`interactable`**.

## Related

* [Recipe: Implement custom VR interactions](/recipes/implement-custom-vr-interaction) — step-by-step guide for creating custom VR interaction components

## Unity Editor

<Frame hint="Valve or Knob prefab root showing MolcaInteractionBase-derived component + XRGrabInteractable." caption="Molca interaction + XRGrabInteractable">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/ptmolcateknologinusantara/images/features/vr/interactions/molca-interaction-base-inspector.png" alt="MolcaInteractionBase-derived component in Inspector" />
</Frame>
