Overview
Interactions between virtual hands and scene objects in OctoXR are driven by 3 components:
Interactor acts as a source object that starts an interaction with Interactable objects, it is usually attached to a virtual hand object or somewhere in its hierarchy. It uses certain support constructs to find the objects with which it can potentially interact, then evaluate if it can actually start to interact with them and finally, if it can, start the interaction by notifying Interactable object and its associated InteractionController about interaction state transitions. Interactor also constantly evaluates its currently in-progress interactions and checks if various conditions for ending them are met and, if they are, ends the interactions with Interactable objects. The conditions for interaction start/end can all be configured on Interactor, as well as Interactable and InteractionController.
Interactable is base component that is attached to any object that an Interactor can interact with. This is an abstract class and is meant to be derived from in order to implement various types of Interactables. Currently there is only one concrete type of Interactable in OctoXR - GrabInteractable. It consists of various properties that can be configured in order to drive the grab type of interactions with objects the GrabInteractable is attached to.
Every Interactable has an InteractionController associated with it. InteractionController is responsible for implementing the behaviour of the object when it is being interacted with. For example there are various Grab type of InteractionControllers that are responsible for moving the object they are attached to to various target positions and rotations based on current position/rotation of various other objects that are involved in the current interaction with GrabInteractable. Every Interactable must have one InteractionController associated with it, but InteractionController can have multiple Interactables associated (e.g. InteractionController attached to a GameObject that has multiple child object with Interactables attached).
Finally there are several interfaces used by Interactor in order to find Interactables it can potentially interact with and also to check if it can interact with them, and should it continue to interact with them after it has started doing so. These are described in more detail in Interaction trackers and indicators section.
Interaction stages
There are two main stages Interactors and Interacables go through from starting interactions to ending them.
Hover: Interactor first finds the Interactables it can potentially interact with (usually through some spatial query like ray cast or sphere overlap). All Interactables found this way are then evaluated if they can be hovered by the Interactor. If the Interactable can be hovered, then it enters the hover stage. All Interactables that are currently hovered by the Interactor, but not yet interacted with, are constantly evaluated for continuing the hover state. If the hovering can no longer continue, Interactable is no longer considered for interaction by the Interactor and the process above continues.
Interaction: All hovered Interactables are constantly evaluated by Interactor for interaction start. If the Interactor starts the interaction, Interactable is then promoted from hovering to interacting state, however the Interactable is not immediately considered as stopped being hovered (events relevant for hover stopping are not triggered). As long as the interaction is in progress, Interactable is not evaluated for hovering state, it is only evaluated for continuing the interaction. If at some point the Interactor can no longer maintain interaction with Interactable, Interactable state is demoted from interacting to hovering and it enters the previously described hovering state evaluation.
Whether hovering and interacting states can start, continue or stop is all controlled via various properties on Interactor, Interactable and InteractionController as well as overrides of various methods on concrete implementations of the Interactable and InteractionController - everything can be customized this way to achieve great flexibility in behaviors of different interactions.
Last updated