Skip to main content
File: Assets/_MolcaSDK/_VR/Scripts/Interactions/ValveInteraction.cs
Base: MolcaInteractionBase

Setup

XRGrabInteractable on the handle + ValveInteraction + optional ReferenceableComponent for ValveStep.

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:
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 reachedValveStep 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

Scene view: hand on valve + Inspector: ValveInteraction fields (handle, axis, limits).

ValveInteraction in Unity Inspector