HomeModule plugins › 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

AFM_Abilities AFM_AutoDestroy AFM_Spline

Required by

AFS_UX_Select

4 assets24 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. Enable AFM_WidgetInteraction.
  2. Add BPC_WidgetInteraction to the ability that should drive UI, or use the helper actor.
  3. 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 plugin. Expand an asset to see its members.

Components

BPC_WidgetInteraction10 members
extends SceneComponent
KindNameSignatureDescription
varTrace DistanceSettingsfloatHow far the pointer reaches when looking for a widget to interact with.
varAutoPressOnContactSettingsboolPresses 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.
fnIsHoveringWidgetState(out HoveringWidget: bool)Returns whether the pointer is currently over an interactive widget.
fnReleaseMouseButtonInput()Releases the simulated mouse button on the hovered widget.
fnPressMouseButtonInput()Presses the simulated mouse button on the hovered widget.
fnScrollInputInput(ScrollDelta: float)Sends a scroll wheel delta to the hovered widget.
fnUpdateSourceInfoSource Info(SourceInfo: ST_SourceInfo)Records which ability is driving this pointer, so the widget can tell which hand or player is interacting.
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_PointerIndexCounter1 members
extends ActorComponent
KindNameSignatureDescription
fngetFreePointerIndex(out IndexCounter: int)Returns an unused pointer index, so multiple simultaneous pointers do not collide in UMG.
BP_Helper_WidgetInteraction12 members
extends Actor
KindNameSignatureDescription
varScaleStylefloatSize multiplier for the cursor and laser visuals.
varColorStyleLinearColorColour of the cursor and laser.
varSound_PressSoundSoundBaseSound played when this pointer presses a widget.
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.

Libraries

BFL_WidgetInteraction1 members
extends BlueprintFunctionLibrary
KindNameSignatureDescription
fnWidgetInteraction_GetFreePointerIndex(const Context: Object, __WorldContext: Object, out IndexCounter: int)Returns an unused UMG pointer index for this world. Call once per pointer so several hands can drive the same UI.