Table of Contents

Ray Interaction

This interaction is used to do point and click with any of the platforms that VIROO supports:

  • XR with controllers: point with the controller and press the trigger button.
  • XR with hands: point with your hand and do the pinch gesture.
  • Desktop: aim with the mouse and press click.
  • CAVE: aim with the flystick and press the trigger button.

The Ray interaction consists of:

  • Ray Interactor: XRRayInteractor is the interactor which performs this kind of interaction. This component is provided by Unity´s XR Interaction Toolkit. VIROO provides already configured Ray Interactors attached to the controllers and hands in VR mode and, in Desktop mode, the interaction works through the mouse cursor.
  • Simple Interactable: XRSimpleInteractable is the component with which XRRayInteractor interacts.
  • Viroo XR Simple Interactable: this component is in charge of configuring the way XRSimpleInteractable interacts with the interactors and also that the interaction events are triggered to all users in session through the network.

Add a Ray Interaction to a GameObject

To add ray interaction to an object you must:

  1. Set up the interactable object with the necessary components.
  2. Configure the events you want to handle.

Set up the Ray Interactable object

To make an object respond to a Ray interaction it must have, at least, the following components.

  • XRSimpleInteractable: Unity´s XR Interaction Toolkit component.
  • Collider: this GameObject or its children must have one or more colliders.
  • NetworkObject: necessary to identify the GameObject by VIROO Networking.
  • VirooXRSimpleInteractable: necessary to setup how XRSimpleInteractable is interacted and to launch the events through the Network.

XRSimpleInteractable

This is a Unity´s XR Interaction Toolkit component and is the simplest version of an Interactable object. It is intended to be used as a way to respond to interaction events with no underlying interaction behavior. For more information please refer to the official documentation here.

Important

The XRSimpleInteractable component must be in the Default layer.

Collider

For Ray Interactor to interact with Simple Interactable, it is necessary that there is at least one collider, which can be at the same level of the component or in one of its children. The collider can NOT be of type Trigger.

NetworkObject

For network functions to work properly, interacting components need this component that uniquely identifies them across the network. It is therefore important to ensure that their ObjectId identifier is not repeated.

VirooXRSimpleInteractable

This VIROO component is necessary to setup how XRSimpleInteractable is interacted and to launch the events through the Network.

The XRSimpleInteractable component by default does not differentiate if it is being interacted by a Direct Interactor, Ray Interactor or a Gaze Interactor. That is why VIROO, through this component, provides a way to limit the way in which it interacts with this interactable in order to configure it so that it can only be interacted by an interactor of one type and not by both.

Field Description
Send Network Events If this box is checked the events triggered by the XRSimpleInteractable (HoverEnter, Activate...) will be networked, otherwise the events will be triggered only locally.
Allow Direct Interaction If this checkbox is checked it means that the associated interactable will interact with a Direct Interactor.
Interact With Hands In this field you can specify whether the interactable is hand-interactable. It has four possible values, None, Left, Right, Both. Allow Direct Interaction must be checked.
Tag Filters If you want the interactable to interact only with specific DirectInteractors, you can define tags for this purpose. For more information check the Custom Direct Interactors section in this page. Allow Direct Interaction must be checked.
Allow Ray Interaction If this checkbox is checked it means that the associated interactable will interact with a Ray Interactor and Gaze Interactor.
Allow Distance Select Interactor Check this checkbox to allow the interactable to be selected remotely through a Ray Interactor instead of having to use a Direct Interactor. It is commonly used to be able to grab objects from a distance.

Normally the standard configuration when we want to have a Ray Interaction is to have Allow Direct Interaction disabled and Allow Ray Interaction enabled.

viroo-simple-interactable-interaction-settings.png

Configuring the Events

At this point you can use XRSimpleInteractable events to trigger logic when the Ray Interaction happens. VIROO Interaction System ensures that XRSimpleInteractable events are propagated over the network to all users if Send Network Events is selected. With this, the events you subscribe will be called to all users in the VIROO Application.

If you want to use the VIROO Interaction System Actions and you are sending events through the network, you must use the LocalExecute functions (instead of Execute).

In the following example a MoveAction is triggered when the object is interacted by ray.

grab-interaction-event.png

Here are the most common events that are used when performing Ray Interaction.

Event Description
Activated The event that is called when the selecting Interactor activates this Interactable. This is a generic event when an Interactor wants to activate an Interactable, such as from a trigger pull on a controller or a mouse button down on Desktop.
Deactivated The event that is called when an Interactor deactivates this Interactable. This is a generic event when an Interactor wants to deactivate an Interactable, such as from a trigger release on a controller or mouse button up on desktop.

A complete list of all events is available here