LibraryInteractors: Ray Interactor, Direct Interactor

Interactors: Ray Interactor, Direct Interactor

Learn about Interactors: Ray Interactor, Direct Interactor as part of AR/VR Development with Unity XR

XR Interaction Systems: Ray and Direct Interactors

In Extended Reality (XR) development, particularly within Unity's XR Interaction Toolkit, 'Interactors' are fundamental components that enable users to interact with virtual objects. They define how a user's input (like controller movement or gaze) translates into actions within the XR environment. This module focuses on two primary types of interactors: the Ray Interactor and the Direct Interactor.

Understanding Interactors

Interactors are the bridge between user input and the virtual world. They are typically attached to input devices (like VR controllers or hand tracking) and are responsible for detecting and interacting with 'Interactables' – objects in the scene that are designed to be interacted with. This interaction can range from simple selection to grabbing, manipulating, or activating objects.

What is the primary role of an Interactor in XR development?

An Interactor acts as a bridge between user input and virtual objects, enabling interaction within the XR environment.

The Ray Interactor

The Ray Interactor simulates a ray cast from the user's input device (e.g., a VR controller). This ray extends into the virtual environment, and when it hits an 'Interactable' object, it allows for interaction. This is commonly used for pointing at and selecting distant objects, similar to a laser pointer.

Ray Interactors enable interaction with distant objects via a virtual ray.

Imagine a laser pointer extending from your VR controller. The Ray Interactor works like this, allowing you to target and interact with objects that are not directly in front of you.

The Ray Interactor typically uses a line renderer or a visual beam to indicate the direction and reach of the ray. When this ray intersects with a collider attached to an 'Interactable' object, the Interactor can trigger actions like 'Select', 'Activate', or 'Hover'. This is ideal for navigating menus, selecting buttons, or picking up objects that are out of arm's reach. The length and appearance of the ray can be customized to suit the application's design.

The Direct Interactor

The Direct Interactor simulates a more physical, hands-on interaction. It's used when the user's virtual hand or controller is in close proximity to an 'Interactable' object, allowing for direct manipulation like grabbing, pushing, or touching.

Direct Interactors facilitate physical, close-range interactions with virtual objects.

Think about picking up a real-world object. The Direct Interactor mimics this by allowing your virtual hands or controllers to directly touch and manipulate objects when they are close.

This type of interactor is often associated with hand tracking or controller models that represent the user's hands. When the collider of the Direct Interactor (e.g., the collider on a virtual hand) overlaps with the collider of an 'Interactable' object, interaction can occur. This is crucial for actions like picking up and holding objects, turning knobs, or pressing buttons that require physical contact. The 'Grab' action is a common use case for Direct Interactors.

Comparison: Ray vs. Direct Interactor

FeatureRay InteractorDirect Interactor
Interaction TypeDistance-based (pointing)Proximity-based (touching/grabbing)
Common Use CasesMenu navigation, distant selection, UI interactionGrabbing objects, physical manipulation, button pressing
Visual RepresentationRay/beamVirtual hand/controller collider
Required InputController/Gaze directionController/Hand position and proximity

Choosing the right interactor depends on the desired user experience and the nature of the interaction. Often, applications will utilize both Ray and Direct Interactors to provide a comprehensive interaction system.

Implementation in Unity XR

In Unity, you typically add these interactors as components to your XR rig (e.g., on your VR controller GameObjects). You'll also need to ensure your target objects have appropriate colliders and the 'XR Interactable' script (like 'XR Grab Interactable' or 'XR Simple Interactable') attached to them. The XR Interaction Toolkit provides a robust framework for setting up these interactions.

Visualizing the interaction flow: A Ray Interactor casts a ray from the controller. If it hits an 'Interactable' object with a collider, a 'Select' event can be triggered. A Direct Interactor uses a collider on the controller/hand. When this collider overlaps with an 'Interactable' object's collider, a 'Grab' or 'Select' event can occur.

📚

Text-based content

Library pages focus on text content

Learning Resources

Unity XR Interaction Toolkit Documentation(documentation)

The official Unity documentation for the XR Interaction Toolkit, covering core concepts and components like Interactors.

XR Interaction Toolkit: Interactors Overview(documentation)

Detailed explanation of different interactor types, including Ray and Direct Interactors, within the Unity XR Interaction Toolkit.

Unity Learn: XR Interaction Basics(tutorial)

A learning path on Unity Learn that introduces the fundamentals of XR development and interaction systems.

Creating XR Interactions with Unity's XR Interaction Toolkit(video)

A video tutorial demonstrating how to set up and use the XR Interaction Toolkit, including common interactor patterns.

Unity XR Interaction Toolkit: Grab Interactable Tutorial(video)

A focused tutorial on implementing the 'Grab Interactable' component, which is commonly used with Direct Interactors.

Understanding XR Interaction: Raycasting vs. Direct Manipulation(video)

Explains the conceptual differences and use cases for raycasting and direct manipulation in XR interfaces.

Unity XR Interaction Toolkit: Ray Interactor Example(video)

A practical demonstration of setting up and using the Ray Interactor for UI and object selection in Unity.

Best Practices for XR Interaction Design(blog)

Articles and insights on designing intuitive and effective interactions for virtual and augmented reality experiences.

XR Interaction Toolkit: Interactable Components(documentation)

Details on the various 'Interactable' scripts that objects need to respond to Interactor events.

Introduction to Extended Reality (XR)(wikipedia)

A foundational overview of Extended Reality, including VR, AR, and MR, providing context for interaction systems.