Table of Contents

Grab Interaction

Grab Interaction allows you to create objects in your experience that users can pick up and manipulate. You can perform this interaction with any of the platforms that VIROO supports:

  • XR with controllers: touch the object to be grabbed with the controller and press the grip button.
  • XR with hands: place your hand on the object and perform the pinch gesture.
  • Desktop: touch the object to be grasped with the on-screen controller and press the G (left controller) or H (right controller) keys.
  • CAVE: touch the object to be grabbed with the flystick and press the grip button.

The Grab 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.
  • Grab Interactable: XRGrabInteractable is the component with which XRDirectInteractor interacts. Allows for basic grab functionality. When this behavior is selected (grabbed) by an Interactor, this behavior will follow it around and inherit velocity when released.
  • Viroo XR Grab Interactable: this component is in charge of configuring the way XRGrabInteractable interacts with the interactors and also that the interaction events are triggered by networking.

Add a Grab Interaction to a GameObject

To add grab interaction to an object you must:

  1. Configure the Grabbable Object with the necessary components.
  2. Use the XRGrabInteractable events if you want to add logic when interacting with it.

Set up the Grab Interactable object

To make an object grabbable it must have, at least, the following components.

  • XRGrabInteractable: component of Unity's XR Interaction Toolkit package.
  • Rigidbody: XRGrabInteractable depends on this component, if it did not exist it will be added when adding the previous one.
  • Collider: a Collider must be added, in this same GameObject or within its hierarchy.
  • NetworkObject: VIROO Networking system component. NetworkGrabbable depends on it. The Generate Object Id button must be clicked to assign it a unique identifier.
  • NetworkTransform: VIROO Networking system component. Necessary to synchronize the position of this object for the rest of the users.
  • VirooXRGrabInteractable: necessary to setup how XRGrabInteractable is interacted and to launch the events through the Network.

XRGrabInteractable

This is a Unity´s XR Interaction Toolkit component. Interactable component that allows for basic grab functionality. When this behavior is selected (grabbed) by an Interactor, this behavior will follow it around and inherit velocity when released.. For more information please refer to the official documentation here.

Collider

For Direct Interactor to interact with Grab 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.

VirooXRGrabInteractable

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

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

viroo-xr-grab-interactable.png

Configuring the Events

At this point you can use XRGrabInteractable events to trigger logic when interacting with the grabbable. VIROO Interaction System ensures that XRGrabInteractable 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 grabbed.

grab-interaction-event.png

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

Event Description
SelectEntered The event that is called when an Interactor selects this Interactable. This is a generic event when an Interactor wants to select (grab) an Interactable, such as from a grab button press on a controller or a keyboard interaction on Desktop.
SelectedExited The event that is called when an Interactor deselects this Interactable. This is a generic event when an Interactor wants to deselect (ungrab) an Interactable, such as from a grab button release on a controller or a keyboard interaction on Desktop.
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 mouse 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 up on desktop.