# Scene Setup
WARNING
This guide assumes pre-existing knowledge of XR Development in Unreal engine. For a more detailed overview, please visit the introductory documentation page (opens new window).
The Snapdragon Spaces Samples contain ready-to-use blueprints for common AR use cases.
# Core blueprints
These blueprints are prepared to work in an AR environment and are the basis for our project.
The BP_GameMode
(located under Content > SnapdragonSpaces > Common > Core
) defines the rules of an experience. Currently, it only sets the default pawn class to custom BP_Pawn
. To avoid customizing it for each map, go to Project Settings > Maps & Modes
and overwrite the Default GameMode.
In Unreal Engine, a pawn is the physical representation of the user and defines how the user interacts with the world. The custom BP_Pawn
(located under Content > SnapdragonSpaces > Common > Core
) can be used with a gaze or 3DoF controller for interaction. Furthermore, it also includes an implementation of these interaction controllers for testing them in the editor.
The D_ARSessionConfig
(located under Content/SnapdragonSpaces/Common/Core
) defines what features are used in the AR session. For basic information about this asset, please refer to the Unreal documentation (opens new window). Currently, BP_Pawn defines the session config we are using in our demo.
# Controller blueprints
The implementation for the different controllers is done in components for easy extension or replacement in the actors.
The parent component class BP_ControllerComponent
(located under Content > SnapdragonSpaces > Common > Core > Components
) holds access to the gaze and pointer controller. This blueprint also establishes the basis for managing the interaction and includes some options that are customizable for the developer in all derived controllers.
- bAutoActivate: Indicates if the controller is enabled by default.
- DelayStart: When the app starts or loads a new map, it is the time that should elapse until interaction should be enabled.
# Gaze Controller
The gaze controller BP_GazeControllerComponent
(located under Content > SnapdragonSpaces > Common > Core > Components
), manages the raycasting and interactions with widget actors in the scene as well as the delay interaction functionality and "click" functionality of the pointer.
Gaze Pointer Limitation
Currently, the gaze pointer can only interact with widget actors in the scene, unlike the Pointer Controller, which can interact with both widgets and 3D actors.
Some options are customizable for the developer as:
- bMoveReticleHit: If this boolean is enabled and the user looks at an interactive actor, the reticle moves to the interactive position of the actor.
- TimerDuration: How many seconds the user has to look at something to select it.
- DefaultDistance: When bMoveReticleToHit is active, this sets the distance at which the gaze controller is drawn.
- ReticleOuterRing: Material for the outer ring reticle.
- VerticalBias: The vertical position of the reticle considering 0 the center of the screen, 1 the top of the screen, and -1 the bottom of the screen.
Finally, the reticle, which the samples use to point to the world, is composed of two planes as a Static Mesh Component: one of them with a static material for the inner ring (MI_Reticle_Inner
) and the other uses a dynamic material for the outer ring (MI_Reticle_Outer
). This dynamic material defines a parameter (Percentage) to complete the visual effect of the reticle interaction. In addition, the function Update Reticle Position
(in the component blueprint) uses the outer texture as the parent of the components related to the reticle, and uses it to move them in the interaction hits. The component distinguish each texture using the Component Tags (gaze, gaze_outerring, gaze_parent).
# Pointer Controller
The BP_PointerController
actor (located under Content > SnapdragonSpaces > Common > Placeable
) is ready to manage the 3DoF and 6DoF controllers. Each type of controller is identified getting the profile automatically enabled in Motion Controller Component
, using the microsoft interaction profile as 3DoF and the oculus interaction profile as 6DoF.
The Motion Controller Component
is added as a child of the root component to manage each controller. The Visualization
section of this component allows showing a 3D model in the virtual world following the controller movement in the real world, just enabling the Display Device Model option. In addition, if the developer is interested in showing the default mesh of each device depending on the profile, have to select OpenXR in the Display Model Source option. Otherwise, the developer can select Custom in this option to customize it, and add the mesh in Custom Display Mesh. Finally, in the Motion Controller
section, the developer should assign the type of input.
SELECTING MOTION SOURCE
Setting up the 3DoF, the input selected should be Left.
Setting up the 6DoF, the input selected could be Left or Right depending on which hand the controller is designed in.
The developer should add a Widget Interaction Component
to manage the controller interaction, and this component should be a child of the Motion Controller Component
.
In the last step, to visualize the pointer, a Static Mesh Component
, called Laser Pointer Mesh, has been added in the samples as a child of the Motion Controller Component
that has the interaction enabled.
WARNING
Currently, the sample project is not implemented to support interaction with more than one controller at the same time. For this reason, the proposed structure is only used for one of the controllers and always interacts with the right hand.
# Input Cheat Sheet
Buttons used for input actions:
Host Controller | Right XR Controller | Left XR Controller | |
---|---|---|---|
Select | Tap on Trackpad | Right Trigger Button | Left Trigger Button |
Gaze/Pointer switch | Menu Button | None | Left Menu Button |
Touchpad | Trackpad | None | Left Joystick |
Anchor Position Confirmation | Tap on Trackpad | Any Trigger Button | Any Trigger Button |
# UI
The 3D Widgets located in the world must be created using the blueprint BP_3DWidget
(located under Content > Snapdragon > Common > UI
) and define the UI in the WidgetComponent. To work with the gaze or pointer controller, it must be a child class of this class.