Table of Contents

Direct Interaction

This interaction is used to detect when an object is touched by another. The most common case is when an object is touched with the controller or hand tracking, but it is also used to detect collisions with other objects.

The Direct interaction consists of:

  • Direct Interactor: XRDirectInteractor is the interactor which performs this kind of interaction. This component is provided by Unity´s XR Interaction Toolkit. By default VIROO provides already configured Direct Interactors attached to the controllers and hands.
  • Simple Interactable: XRSimpleInteractable is the component with which XRDirectInteractor 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 by networking.

Add a Direct Interaction to a GameObject

To add direct 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 Interactable object

To make an object respond to a Direct 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 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 Direct 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 be of type Trigger or not, but if it is of type Trigger, it must be dragged in the Colliders field of the XRSimpleInteractable component, it will not register it automatically as it does with the non-trigger colliders.

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 interactable 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 Direct Interaction is to have Allow Direct Interaction enabled and Allow Ray Interaction disabled.

viroo-simple-interactable-direct-interaction.png

Custom Direct Interaction

If instead of interacting with controls or hands, we want a specific object to interact with a Simple Interactable, we must define our own custom DirectInteraction. To do this we will do the following:

Setting up the Interactor

  1. Create new GameObject.
  2. Add a Collider and make it trigger type. Adjust the size to fit your needs.
  3. Add a Rigidbody and to prevent it from falling: deactivate gravity and make it kinematic.
  4. Add XRDirectInteractor component to the GameObject.
  5. Add VirooXRDirectInteractor component. Fill the TagFilter field with an identifying string.
VirooXRDirectInteractor
Field Description
Tag Filter The text label with which this Interactor is identified.

viroo-direct-interactor.png

Setting up the Interactable

  1. Create new GameObject.
  2. Add a Collider and make it trigger if you need it to be. Adjust the size to fit your needs.
  3. Add XRSimpleInteractable component. In the InteractableEvents section locate the HoverEntered event and drag into it what you want to be done when the interaction occurs.
  4. Add a VirooXRSimpleInteractable and in the Interaction Settings section select None in the Interact With Hands section. In the Tag Filters field add a new entry and type the same string you put in the TagFilter of the VirooXRDirectInteractor field. Finally, disable the Allow Ray Interaction field.

viroo-simple-interactable-interaction-settings.png

Configuring the Events

At this point you can use XRSimpleInteractable events to trigger logic when direct 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.

direct-interaction-event.png

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

Event Description
Hover Entered The event that is called when an Interactor begins hovering over this Interactable.
Hover Exited The event that is called when an Interactor ends hovering over this Interactable.

A complete list of all events is available here