Skip to main content

Raycast Interactions

The HoloMIT SDK’s raycast interaction module allows users to point and select objects at a distance using a visual ray and pointer. It provides hover events and fires actions with ButtonX, based on tag-filtered raycasts.


Overview

  • Draws a ray from the controller to visualize potential interactable targets.
  • Detects hover enter/exit based on the selectableTag and fires HoverEnterEvent/HoverExitEvent.
  • Fires a selection event when ButtonX is pressed on a hit collider with a NetworkTrigger.

Requirements

  • Unity 2022.3 LTS or later
  • New Input System (for reading LeftTrigger, LeftGrip, ButtonX)
  • XR Interaction Toolkit (for controller tracking)
  • HoloMIT Core & EventManager (for NetworkTrigger and hover events)
  • InteractionRaycast prefab placed under your player rig
  • Project tags defined:
    • Selectable for objects that can be pointed at
    • ObjectDragger for draggable objects (if used)

Setup

  1. Place InteractionController
    • Add the InteractionRaycast component to your player.
  2. Configure the Component
    • On the InteractionController component, assign:
      • lineSelectableMat / lineNotSelectableMat for valid/invalid targets
      • References to LineRenderer and targetMarker for visuals
      • leftHand and rightHand transforms (if not auto-detected)
      • selectableTag (default: “Selectable”) and dragTag (default: “ObjectDragger”)
      • maxDistance and raycastLayers to define range and layers
  3. Enable Input Actions
    • InteractionController uses the HoloMITControls asset for trigger and ButtonX bindings.
  4. Test Tags and Layers
    • Tag your interactable GameObjects accordingly
    • Verify that the ray and marker appear when pointing

Exposed Parameters

PropertyTypeDescription
lineSelectableMatMaterialMaterial when the ray hits a selectable object.
lineNotSelectableMatMaterialMaterial when the ray does not hit a selectable object.
lineRendererLineRendererComponent that draws the ray.
targetMarkerGameObjectVisual indicator at the hit point.
leftHandTransformOrigin transform for left-hand raycasts.
rightHandTransformOptional origin for right-hand raycasts.
selectableTagstringTag for hover/select detection (default: Selectable).
dragTagstringTag for draggable objects (default: ObjectDragger).
maxDistancefloatMaximum raycast distance (default: 20).
raycastLayersLayerMaskLayers considered for raycast collisions.

Usage

  • Activate Ray: Hold the left trigger (while not gripping) to enable the ray and marker.
  • Hover: Move the ray over objects tagged Selectable; hover events fire automatically.
  • Select: Press ButtonX while pointing at a valid object; its NetworkTrigger will fire.
  • Cleanup: Release the trigger to hide the ray and marker.

Known Limitations

  • Configured only for the left hand by default; extend to both hands if needed.
  • No smoothing transitions; the ray appears/disappears instantly.
  • Relies on Unity physics and tags; ensure accurate collider and tag setup.
  • Does not support drag operations out of the box; additional logic required.