Snap Interactions
Design Guideline: Providing a comfortable hand tracking experience is essential for creating immersive and enjoyable apps. Refer to the
Hand Tracking Design Guide to learn about best practices and to minimize risks of user discomfort.
Snap interactions allow items to automatically snap to poses in the environment. The DistanceGrabExample scene uses them to simply have the items snap back to their original position when not in use, but it is possible to create custom behaviors so the objects can snap to things like inventories, cells in a board game, or slots around the user body. To try snap interactions in a pre-built scene, see the
SnapExamples scene.
The
SnapInteractor
is the
Interactor
class for this interaction. This component is placed in the item that you want to be able to snap, like a chess piece, and will take care of detecting nearby
SnapInteractable
s and move the item towards the best available pose provided by them.
When the optional Time Out Interactable and Time Out are provided, the interactor will automatically move to said interactable after Time Out seconds if the grabbable is not selected or hovered by any other interactor.
The
SnapInteractable
component is the
Interactable
class for this interaction. When used as-is it provides a single pose in space to which the interactors can snap too, but optionally it can be enhanced in several ways:
- Movement Provider, by referencing a
MovementProvider
the method for snapping can be fully customized. By default the interactor will follow the slot at a fixed speed, but following the different MovementProvider
it could trace a curve, add easing, etc. - Snap Pose Delegate, the
ISnapPoseDelegate
interface allows creating multiple poses within a SnapInteractable
. Implementing and providing this interface is useful for using a single SnapInteractable
for all the cells within a board in a board game, or to define all the different slots in an inventory system, allowing to even move snapped items when hovering new interactors to make room.