Home › Systems › AFS_UX_Select
System

AFS_UX_Select

Selection by fingertip, laser or desktop click, with priority resolution and interface-based vetoes.

What it gives you

  • One interaction that works with mouse, laser and fingertip
  • Priority resolution when objects overlap
  • Hit-location override for precise pointing

Requires

AFA_Sounds AFL_Libraries AFM_Abilities AFM_AutoDestroy AFM_Spline AFM_WidgetInteraction AFS_Core_MotionController AFS_UX_Grip

Required by

AFS_UX_Grip AFS_UX_Laser AFS_UX_Teleporter AF_Examples

8 assets30 API members

Description

Select is the smallest complete interaction stack in the framework and the best one to read when learning the pattern.

BPC_PawnAbility_Select traces from the pawn and resolves the highest-priority selectable component under the cursor. BPC_Interaction_Select on the target declares selectability and fires On Select. Interface_Select on the owning actor can veto, or redirect where a pointer appears to hit.

The same interaction serves all three input methods, because the ability supplies the trace and the target only cares about the resulting Source Info.

Setup

  1. Confirm BPC_PawnAbility_Select is on the pawn, and BPC_ControllerAbility_Hand_Laser or _Hand_Finger on the motion controllers for VR.
  2. Add BPC_Interaction_Select to any actor and bind On Select.

Usage

Basic selection

See Make an object selectable.

Vetoing

Implement Interface_Select and return Override = true with Is Selectable = false.

Redirecting the pointer

Implement Select_HitLocationOverride to make a laser terminate at a chosen point rather than the raw trace hit — useful for snapping to a control's centre.

The object selected in play, highlight active
AFS_UX_Select_result.pngThe object selected in play, highlight active
The object selected in play, highlight active

Key properties

PropertyWhen to change
Select SoundFeedback on selection
Relevant ComponentsRestrict which meshes are clickable
Select Interaction StyleThe cursor and accent colour shown while hovering something selectable
Min / Max Laser LengthOn the laser ability, to change reach

Extending

Copy this stack's shape when adding your own interaction type — it is the reference implementation. See Extending the framework.

Multiplayer notes

Multiplayer

BPC_Interaction_Select implements IOutsidePawnRPCInterface, so selection replicates without routing through the pawn. Requires AFPNetDriver.

Example map

Map_Examples_Select covers click, laser and fingertip selection with vetoes.

Troubleshooting

Nothing is selectable. The pawn is missing BPC_PawnAbility_Select, or the object's meshes have no collision on the trace channel.

API reference

Every blueprint asset in this module. Expand an asset to see its members.

Components/ControllerAbilities

BPC_ControllerAbility_Hand_Finger2 members
extends BPC_ControllerAbility

Hand ability giving one motion controller a fingertip poke, for pressing world widgets and near objects at very short range. Add it to a hand controller and position it at the index fingertip, as the showroom hands do, then set the trace distance in centimetres.

KindNameSignatureDescription
varTrace DistanceSettingsfloatHow far ahead of the fingertip the selection trace reaches.
varSound PressSoundSoundBaseCue played when this hand's fingertip presses a widget. It is handed to the widget interaction helper the ability spawns rather than played here, so leaving it empty makes poking UI with this hand silent.
BPC_ControllerAbility_Hand_Laser15 members
extends BPC_ControllerAbility

Hand ability giving one motion controller a pointing laser. It traces ahead of the hand each frame, keeps the highest-priority select interaction highlighted and feeds the widget interaction helper, so world widgets can be clicked and scrolled. Pressing select clicks the widget or presses the interaction. Add it to a hand controller and set the length, thickness and colour.

KindNameSignatureDescription
varMin Laser LengthSettingsfloatShortest the laser is drawn when it hits something close by.
varMax Laser LengthSettingsfloatMaximum reach of the selection laser.
varMapping Contexts DefaultInputST_MappingContext_SideInput mapping contexts applied for the left and right hand.
varSound PressSoundSoundBaseCue played when this hand's laser presses a widget. It is handed to the widget interaction helper the ability spawns rather than played here, so leaving it empty makes clicking UI with the laser silent.
varThicknessSettingsfloatThickness of the laser beam.
varColorSettingsLinearColorColour of the laser beam.
varShoulder OffsetVectorEstimated shoulder position relative to the head, the laser aims from it.
varAim Interp SpeedfloatSpeed at which the aim follows the hand.
varAim Interp Speed SteadyfloatSlower aim speed while the hand moves only a little, to steady the beam.
varAdapt Range DegreesfloatAngle below which a hand movement counts as small and uses the steady aim speed.
fnSetWidgetFocus(Set: bool)Gives this hand's focus to the laser while it points at an interactive widget, and hands it back when it stops, like the controller laser does. While the laser has the focus the hand's other abilities pause, so the thumbstick scrolls the widget instead of moving the player. Only acts when the state changes (Has Widget Focus): called from Tick on a hover change, and with false when the ability is deactivated, where it does nothing unless the laser holds the focus.
fnIsHandtracking?(out Active: bool)—
fnAimFromShoulderDefault(DeltaSeconds: float)Turns the laser to point along the line from the estimated shoulder through the hand, easing at the aim speeds.
fnHandleSelectDefault()Runs a selection against whatever the laser is currently pointing at.
fnSetHoverStateDefault()Updates the laser's hover appearance and returns an alternate endpoint when the target overrides its hit location.

Components/Interactions

BPC_Interaction_Select5 members
extends BPC_Interaction · implements OutsidePawnRPCInterface

Interaction making its owner selectable, whether by a hand laser, a fingertip or a desktop click. It answers whether it may be selected right now, lets the owner veto or move the reported hit point through the select interface, and on press broadcasts On Select with the source info, plays the select sound and fires the haptic effect. Add it to any actor that should respond to being clicked.

KindNameSignatureDescription
varSelect SoundSoundSoundBaseSound played at the hit location when this object is selected.
fnHandleSelect(Source Info: ST_SourceInfo, Hit Result: HitResult)Broadcasts On Select without playing feedback, for triggering a selection from code.
fnOverrideHitLocationSelect(out Override: bool, out HitLocation: Vector)Lets the owner supply a different hit location, so a laser can terminate on a chosen point rather than the raw trace hit.
fnCan be SelectedSelect(HitComponent: PrimitiveComponent, SourceInfo: ST_SourceInfo, out CanBeSelected: bool)Returns whether this object may currently be selected by the given source, consulting Interface Select on the owner if implemented.
eventSelectPressed(SourceInfo: ST_SourceInfo, HitResult: HitResult)Fires when the object is selected, playing sound and haptics. Bind to On Select to react.

Components/PawnAbility

BPC_PawnAbility_Select3 members
extends BPC_PawnAbility

Pawn ability giving a desktop or mobile pawn the select action. Each tick it highlights the highest-priority select interaction under the pawn's trace and sets the pawn's interaction state from the chosen style; the select input then presses that interaction. Add it to a pawn along with its input mapping context. VR pawns use the hand laser instead.

KindNameSignatureDescription
varInput SelectInputInputMappingContextInput mapping context enabled while this ability is active, carrying the select action.
varSelect Interaction StyleStylePDA_InteractionStateInteraction state requested while hovering something selectable, controlling the cursor and accent colour.
eventSelect()Runs a selection against whatever the pawn is currently pointing at.
BPC_PawnAbility_Widget2 members
extends BPC_PawnAbility

Pawn ability letting a desktop or mobile pawn use world-space widgets. It adds a widget interaction component on activation, feeds it the pawn's latest trace, maps press and scroll input onto it and passes the source info to widget components that ask who is pointing at them. Add it to a pawn beside the select ability; without it, widgets in the world cannot be clicked.

KindNameSignatureDescription
varInput WidgetInputInputMappingContextInput mapping context enabled while this ability is active, carrying the widget interaction actions.
varWidget Interaction StyleStylePDA_InteractionStateInteraction state requested while hovering a widget.

Helpers

BP_Helper_ControllerAbility_Hand_Finger0 members
extends BP_Helper_ControllerAbility

Per-hand helper actor for the fingertip ability, carrying the select and hover spheres and the widget interaction component that presses world widgets at the fingertip. Spawned by the ability rather than placed, and nothing else in the framework references it; subclass it only if the fingertip needs different collision.

No editor-visible members; this asset configures defaults only.

BP_Helper_ControllerAbility_Hand_Laser1 members
extends BP_Helper_ControllerAbility

Per-hand helper actor for the hand laser. It holds the VR select and scroll input bindings and forwards them, after checking they came from its own hand, to the laser ability that spawned it. Spawned by the ability rather than placed; subclass it to bind extra input to the laser.

KindNameSignatureDescription
varController Ability Hand LaserBPC_ControllerAbility_Hand_LaserThe laser ability this helper draws for.

Interfaces

Interface_Select2 members
extends Interface

Contract an actor implements to control its own selection. Can Be Selected can refuse a select, or defer by leaving the override off, and Select Hit Location Override replaces the point the ability reports back. Implement it on the actor owning a select interaction; without it, selection is always allowed and the real impact point is used.

KindNameSignatureDescription
fnSelect_HitLocationOverrideSelect(out Override: bool, out NewHitLocation: Vector)Implement to redirect where a pointer appears to hit this object, for example snapping a laser to a control's centre.
fnCanBeSelectedSelect(SelectComponent: BPC_Interaction_Select, SourceInfo: ST_SourceInfo, out Override: bool, out IsSelectable: bool)Implement on an actor to veto or allow selection under your own conditions. Return Override true and Is Selectable false to block; not implementing the interface means always selectable.