Skip to main content

Raycast Interactions

HeaderRaycastInteractions

The 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

Setup

  1. Place InteractionController
    • Add the InteractionRaycast Prefab component to your player.

InteractionRaycast

  1. Configure the Component
    • On the InteractionController component, assign:

InteractionController

  • lineSelectableMat / lineNotSelectableMat for valid/invalid targets
  • References to LineRenderer and targetMarker for visuals
  • leftHand transform (if not auto-detected)
  • maxDistance and raycastLayers to define range and layers
  1. Enable Input Actions
    • InteractionController uses the HoloMITControls asset for trigger and ButtonX bindings.

Usage

  • Activate Ray: Hold the left trigger to enable the ray and marker.

ActivateRay

  • Select: Press ButtonX while pointing at a valid object; its NetworkeTrigger 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.