Skip to main content

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 to interact with, such as a button and a scrollbar. While the buttons are usable with both a gaze pointer and a device pointer, the scrollbar in the sample is only usable with the device pointer. Additionally, another UI element in the scene showcases the input coming from the host controller's touchpad.

Lastly, an interactive cube object can be grabbed with the controller, in order to demonstrate 3D object interaction. To make it a valid interactive actor it needs to have a collision overlapping or blocking the 3DWidget channel, and it needs the BPI_Interactable (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 BP_PointerControllerComponent 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 BP_ControllerComponent (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_PointerController 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