Home › Modules › AFM_WidgetInteraction
Module

AFM_WidgetInteraction

Wraps Unreal's widget interaction with pointer index management, a cursor and a laser material, so several pointers can drive UMG at once.

What it gives you

  • Multiple simultaneous UMG pointers
  • A themed cursor and beam
  • Scroll and press forwarding from any ability

Requires

AFA_Sounds AFL_Libraries AFM_Abilities AFM_AutoDestroy AFM_Spline

Required by

AFS_UX_Select

2 assets23 API members

Description

Unreal's widget interaction component assumes one pointer. In VR there are at least two hands, and in multiplayer several players may drive the same replicated UI. AFM_WidgetInteraction adds pointer index management so each pointer gets a unique index and they do not interfere.

BP_Helper_WidgetInteraction provides the visible cursor and beam, and forwards presses, releases and scroll input attributed to the Source Info that triggered them.

Setup

  1. Add BPC_WidgetInteraction to the ability that should drive UI, or use the helper actor.
  2. Set Trace Distance and Auto Press On Contact to suit pointing or direct touch.

Usage

Pointing at UI

Pair with the laser ability. The laser supplies direction; this component supplies the UMG events.

Touching UI directly

Set Auto Press On Contact true for finger-touch UI, so no button press is required.

Getting a pointer index

Call WidgetInteraction_GetFreePointerIndex once per pointer.

Two hands driving one interface at once
AFM_WidgetInteraction_result.pngTwo hands driving one interface at once
Two hands driving one interface at once

Key properties

PropertyWhen to change
Trace DistancePointer reach
Auto Press On ContactDirect-touch UI rather than pointing
Sound PressFeedback on press

Extending

Derive from BP_Helper_WidgetInteraction for a custom cursor or beam.

Example map

Used throughout Map_Examples_UI.

Troubleshooting

Two pointers fight over the same widget. Both are using the same pointer index — obtain each from WidgetInteraction_GetFreePointerIndex.

API reference

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

Components

BPC_WidgetInteraction10 members
extends SceneComponent

Component giving its owner a UMG pointer of its own: while active it spawns the widget interaction helper, which draws the beam and the cursor and forwards presses, releases and scrolling to whatever widget the trace lands on. Add it to an actor that has to work widgets without being a motion controller; the laser and the hand abilities carry their own instead.

KindNameSignatureDescription
varTrace DistanceSettingsfloatHow far the pointer reaches when looking for a widget to interact with.
varAuto Press on ContactSettingsboolPresses automatically when the pointer touches a widget, instead of waiting for an input. Use for direct-touch UI.
varSound PressSoundSoundBaseSound played when the pointer presses a widget.
fnUpdateSourceInfoSource Info(SourceInfo: ST_SourceInfo)Records which ability is driving this pointer, so the widget can tell which hand or player is interacting.
fnScrollInputInput(ScrollDelta: float)Sends a scroll wheel delta to the hovered widget.
fnPressMouseButtonInput()Presses the simulated mouse button on the hovered widget.
fnReleaseMouseButtonInput()Releases the simulated mouse button on the hovered widget.
fnIsHoveringWidgetState(out HoveringWidget: bool)Returns whether the pointer is currently over an interactive widget.
eventUpdateColor(Color: LinearColor)Changes the pointer and cursor colour, for example to match the current interaction state.
eventOnWidgetHoveredChanged_Event()Internal handler fired when the hovered widget changes.

Helper

BP_Helper_WidgetInteraction13 members
extends Actor

World-side actor driving a UMG widget from a trace: it owns the widget interaction component, the cursor plane drawn on the widget's surface and the short spline reaching out to it, interpolating the cursor between hits so it glides rather than jumps. Spawned by the widget interaction component or by a hand ability, never placed.

KindNameSignatureDescription
varScaleStylefloatSize multiplier for the cursor and laser visuals.
varColorStyleLinearColorColour of the cursor and laser.
varSound PressSoundSoundBaseSound played when this pointer presses a widget.
varInterp SpeedSettingsfloatSpeed at which the beam end follows the trace target.
fnIsHoveringWidget() → boolReturns whether this pointer is currently over an interactive widget.
eventPressMouseButton(SourceInfo: ST_SourceInfo)Presses on the hovered widget, attributed to the given Source Info.
eventReleaseMouseButton(SourceInfo: ST_SourceInfo)Releases on the hovered widget, attributed to the given Source Info.
eventShowCursor(Show: bool)Shows or hides the pointer cursor without deactivating the pointer.
eventDeactivate(DestroyAfterFadeOut: bool)Fades the pointer out, optionally destroying the helper afterwards.
eventActivate()Fades the pointer in and starts tracing for widgets.
eventScrollWheelInput(SourceInfo: ST_SourceInfo, ScrollDelta: float)Sends a scroll delta to the hovered widget, attributed to the given Source Info.
eventSetEndLocation(TargetEndLocation: Vector)Sets where the laser terminates, so it stops at the widget surface rather than passing through.
eventSetCurrentTrace(CurrentTrace: HitResult)Supplies the trace result the pointer should use this frame, when tracing is done by the owning ability.