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

Role

Tracks wrist rotation around the knob axis, applies smoothing and optional snap angles.

Setup

Same pattern as Valve interaction: XRGrabInteractable + component + references for KnobStep.

Code

Inspector onRotationChanged, onPositionChanged, onFullRotation match the Valve interaction pattern:
using MolcaSDK.VR.Interactions;
using UnityEngine;

public class KnobFeedback : MonoBehaviour
{
    [SerializeField] private KnobInteraction knob;

    private void OnEnable()
    {
        knob.onRotationChanged.AddListener(OnAngle);
        knob.onPositionChanged.AddListener(OnSnap);
    }

    private void OnDisable()
    {
        knob.onRotationChanged.RemoveListener(OnAngle);
        knob.onPositionChanged.RemoveListener(OnSnap);
    }

    private void OnAngle(float degrees) { }
    private void OnSnap(int index) { }
}

Troubleshooting

  • Snaps feel wrong — Adjust snapPositions or disable snapToPositions for free rotation; startAngle must match your authored pose.
  • Same as valve: no grab — Confirm MolcaInteractionBase / XRGrabInteractable setup per MolcaInteractionBase.
  • Step does not complete — See KnobStep ( targetAngle vs snap indices).

Unity Editor

Knob prefab with KnobInteraction + snap positions array visible.

KnobInteraction in Unity Inspector