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

Role

  • Discovers XRGrabInteractable
  • Tracks which interactor is active
  • Lock / unlock interaction
  • Implements analog interaction contracts used by valve/knob flows
Concrete types: Valve interaction, 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.
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 foundReferenceManager.Register runs after WaitForInitialization; ensure ReferenceManager exists and refId is stable (OnValidate generates ids).
  • Unexpected dropsmaxInteractionDistance > 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.

Unity Editor

Valve or Knob prefab root showing MolcaInteractionBase-derived component + XRGrabInteractable.

MolcaInteractionBase-derived component in Inspector