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:
- Near-Far Interactor: Near-Far Interactor 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 Near-Far Interactors attached to the controllers and hands in VR mode and, in Desktop mode, the interaction works through the mouse cursor.
- XR Simple Interactable: XRSimpleInteractable is the component with which Near-Far Interactor 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:
- Set up the interactable object with the necessary components.
- 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.
- XR Simple Interactable: Unity´s XR Interaction Toolkit component.
- Collider: this GameObject or its children must have one or more colliders.
- Network Object: necessary to identify the GameObject by VIROO Networking.
- Viroo XR Simple Interactable: necessary to setup how XR Simple Interactable is interacted and to launch the events through the Network.
XR Simple Interactable
This is a Unity´s XR Interaction Toolkit component and is the simplest version of an Interactable object. It's 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.
Note
The XR Simple Interactable component must be in the Default
layer.
Collider
For Near-Far Interactor to interact with XR Simple Interactable, it's necessary that there is at least one collider. The collider can be at the same level of the component or in one of its children and can not be of type Trigger.
Network Object
For network functions to work, interacting components need this component that uniquely identifies them across the network. It's important to make sure that their ObjectId identifier isn't repeated.
Viroo XR Simple Interactable
This VIROO component is necessary to setup how XR Simple Interactable is interacted and to launch the events through the Network.
The XR Simple Interactable component by default doesn't differentiate if it's being interacted by a XR Direct Interactor, XR Ray Interactor or a XR Gaze Interactor. That's why VIROO, through this component, provides a way to limit the way in which it interacts with this interactable. It configures 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 checkbox 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 Near-Far Interactor. |
Interact With Hands | In this field you can specify whether the interactable is hand-interactable (controllers and hand tracking). 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 Near-Far Interactor remotely and XR Gaze Interactor. |
Allow Distance Select Interactor | Check this checkbox to allow the interactable to be selected remotely through a Near-Far Interactor. It's commonly used to be able to grab objects from a distance. |
The standard configuration for a Ray Interaction is to have Allow Direct Interaction
disabled and Allow Ray Interaction
enabled.
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 Move Action is triggered when the object is interacted by ray.
To add events to XRSimpleInteractable, expand the Interactable Events
section. Here are the most common events that are used when performing Ray Interaction.
Event | Description |
---|---|
Activated | The event that's 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's 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.