Skip to main content
Version: 1.0

Interaction Sample

This sample demonstrates how to interact with 3D objects and 2D UI in world space.

How the sample works

The sample demonstrates how to interact with UI and other GameObjects in the scene.

The floating UI panel provides common UI elements for interaction, and is split into four main sections. The Input Mode section allows the developer to switch between three supported controller types in the sample:

  • Gaze controller
  • VR controllers or Host controller
  • Hand Tracking controller

Note that on VR devices, the user needs to disconnect the controllers to switch to hand tracking. This can be done by either placing them aside and waiting for a device specific time out or by removing the controllers' batteries. Next, the Buttons and Scrollbar sections show the most common UI elements compatible with any of the controllers. Except the scrollbar, which is not usable with the gaze controller. Lastly, the square UI element displayed in the Touchpad section showcases input provided from the host controller’s touchpad or controllers's thumbstick.

Interaction sample level

An interactive cube object can be grabbed with the controller in order to demonstrate 3D object interaction. To make an actor interactive, add a collider overlapping or blocking the 3DWidget channel. It needs to implement the BI_SpacesInteractable (located under SnapdragonSpacesSamples Content > Snapdragon > Common > Placeable) interface. To add an interface to an actor, go to Class Settings > Interfaces > Implemented Interfaces > Add in the blueprint options.

Class settings

Device Pointer Controller

The implementation of the device pointer controller is separated in multiple blueprints that are described in detail in the chapters below.

Pointer Controller Component

The AC_SpacesController_XRPointer blueprint file (located under SnapdragonSpacesSamples Content > SnapdragonSpaces > Common > Core > Components) can be added to the pawn class, to get interaction with 2D UI and 3D with a pointer.

This component inherits from the parent class AC_SpacesController (see Scene Setup) and scripts the basis for managing the interaction with the world. The only customizable option is Motion Controller Class and refers to the actor class that will spawn when this controller is activated.

Pointer Controller settings

Pointer Controller

The BP_SpacesXRController blueprint file (located under SnapdragonSpacesSamples Content > SnapdragonSpaces > Common > Placeable) manages the raycasting and interaction with widgets and 3D actors. hat use a custom Trace Channel called 3DWidget. Lastly, in order to visualize the device pointer controller, a cylinder mesh is rendered from the origin of the controller along the controller's forward direction. By default, it is colored red, but once it has hit a valid interactive object, it will change its color to green. In addition, the length of the visual is adjusted by taking the raycast hit point as its end.

Pointer controller actor settings