> ## 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.

# ValveInteraction

> Wheel-style valve rotation from hand position with limits and callbacks.

**File:** `Assets/_MolcaSDK/_VR/Scripts/Interactions/ValveInteraction.cs`\
**Base:** [MolcaInteractionBase](/vr/interactions/molca-interaction-base)

## Setup

`XRGrabInteractable` on the handle + **ValveInteraction** + optional [ReferenceableComponent](/core/reference-system) for [ValveStep](/vr/steps/valve-step).

## When to use

Use `Valve Interaction` when a VR training scene needs a physical control the trainee manipulates. Works with the matching step type (e.g. `Valve Interaction` pairs with `valve-interaction`). Configure in Inspector.

## Role

Projects hand motion onto a plane, drives handle rotation, exposes angle subscriptions and limits (see serialized fields and public API in source).

## Code

Inspector **`UnityEvent`** hooks are the usual integration path. From code, the same events are exposed as fields on **`ValveInteraction`**:

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

public class ValveAudio : MonoBehaviour
{
    [SerializeField] private ValveInteraction valve;

    private void OnEnable()
    {
        valve.onRotationChanged.AddListener(OnAngle);
        valve.onFullRotation.AddListener(OnFullTurn);
    }

    private void OnDisable()
    {
        valve.onRotationChanged.RemoveListener(OnAngle);
        valve.onFullRotation.RemoveListener(OnFullTurn);
    }

    private void OnAngle(float degrees) { }
    private void OnFullTurn() { }
}
```

## Troubleshooting

* **Handle does not rotate** — Check **`valveHandle`**, **`rotationAxis`**, **lock** state, and that **`XRGrabInteractable`** fires select events on this rig.
* **Target angle never reached** — **[ValveStep](/vr/steps/valve-step)** uses **`SubscribeToAngle`** against **accumulated** rotation; align **`targetAngle`** with **`min`/`max`** clamp and **`startAngle`**.
* **Jitter or axis wrong** — Toggle **`useInteractableTransform`** vs explicit handle; verify axis is in **handle local space**.

## Unity Editor

<Frame hint="Scene view: hand on valve + Inspector: ValveInteraction fields (handle, axis, limits)." caption="ValveInteraction setup">
  <img src="https://mintlify.s3.us-west-1.amazonaws.com/ptmolcateknologinusantara/images/features/vr/interactions/valve-interaction-inspector.png" alt="ValveInteraction in Unity Inspector" />
</Frame>
