Skip to main content
File: Assets/_MolcaSDK/_VR/Scripts/Scenario/Steps/GrabStep.cs
Base: Step

Role

Completes when the trainee grabs and/or releases an XRGrabInteractable according to serialized rules (auto-find interactable, required interactor, hold duration, optional position checks).

Inspector

All behavior is driven by SerializeField definitions on the component — use the Inspector as the contract for designers.

Code

Completion paths (from selectEntered / selectExited on grabInteractable):
  • completeOnGrab without requireHoldDurationCompleteGrab() runs on grab if ValidateGrabPosition() passes.
  • requireHoldDurationUpdateStep completes once hold time ≥ minGrabDuration and completeOnGrab is true.
  • completeOnRelease — completes on release if not already completed.
  • ForceComplete() — bypasses position checks after setting internal completed flag.
// Designer-driven: assign XRGrabInteractable + toggles in Inspector.
// Runtime override example — require left hand only:
using MolcaSDK.VR.Scenario;
using UnityEngine.XR.Interaction.Toolkit.Interactors;

public class GrabSetup : UnityEngine.MonoBehaviour
{
    public GrabStep step;
    public XRBaseInteractor leftHand;

    private void OnEnable() => step.SetRequiredInteractor(leftHand);
}

Troubleshooting

  • Console: no XRGrabInteractable found — Assign grabInteractable or enable autoFindInteractable and put a XRGrabInteractable on this object or a child.
  • Grab registers but step never completes — Check completeOnGrab vs completeOnRelease, requireHoldDuration / minGrabDuration, interactor filters (allowAnyInteractor / requiredInteractor), and position requirement (targetPosition + positionTolerance).
  • Wrong hand counts — Set requireSpecificInteractor and assign the XRBaseInteractor for the intended controller.

Unity Editor

GrabStep on a prop with XRGrabInteractable in same hierarchy.

GrabStep component in Unity Inspector