Home › Systems › AFS_UX_Gaze
System

AFS_UX_Gaze

Dwell-based interaction: look at an object for a configurable time to trigger it, with a filling indicator.

What it gives you

  • Hands-free interaction for headsets without controllers
  • A configurable dwell time per object
  • Circular and linear indicator styles
  • An accessibility path on every platform

Requires

AFA_Sounds AFL_Libraries AFM_Abilities AFM_AutoDestroy AFS_UI

Required by

AF_Examples

6 assets21 API members

Description

Gaze interaction exists for two audiences: headsets without controllers, and users who cannot use controllers comfortably. It works on desktop and mobile too, where it becomes a look-and-wait interaction driven by the camera.

BPC_PawnAbility_Gaze traces from the camera each frame. BPC_Interaction_Gaze on the target declares a dwell time and an indicator widget, and fires Progress Finished once the player has held their gaze long enough. Interface_Gaze on the owning actor can veto.

The dwell timer is driven by the same tick-and-timeout pattern as highlighting, so looking away cancels it without any explicit event.

Setup

  1. Add BPC_PawnAbility_Gaze to the pawn and set Gaze View Distance.
  2. Add BPC_Interaction_Gaze to the target, set Trigger Time and pick a Widget Progressbar.
  3. Bind to Progress Finished.

Usage

Tuning dwell

Trigger Time is the dwell duration. Under about 0.8 s users trigger things accidentally; over about 2.5 s it feels unresponsive.

Choosing an indicator

Widget_GazeIndicator_Circular reads well on small targets; Widget_GazeIndicator_Linear suits wide ones. Derive from Widget_GazeIndicator for your own.

Vetoing

Implement Interface_Gaze and return false from CanGazeView.

The dwell indicator part-filled on a gazed object
AFS_UX_Gaze_result.pngThe dwell indicator part-filled on a gazed object
The dwell indicator part-filled on a gazed object

Key properties

PropertyWhen to change
Gaze View DistanceHow far gaze reaches from the camera
Trigger TimeDwell duration per object
Widget ProgressbarIndicator style
Sound ProgressbarAudio feedback while dwelling

Extending

Derive from Widget_GazeIndicator and override SetProgress for a custom indicator.

Performance notes

Performance

The gaze ability raises its own tick interval when nothing is hovered, so idle gaze is cheap. Keep Gaze View Distance no longer than the scene needs.

Example map

Map_Examples_Gaze shows dwell interaction on several object types.

Troubleshooting

The indicator never appears. Widget Progressbar is empty, or the object's collision does not block the gaze trace.

API reference

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

Components

BPC_Interaction_Gaze8 members
extends BPC_Interaction · implements OutsidePawnRPCInterface

Interaction that responds to being looked at. While a pawn's gaze ability holds its trace on the owner, an indicator appears just off the surface facing the camera and fills over Trigger Time, then fires. Add it to any actor that should be worked without a controller, set the indicator widget and the time, and implement the gaze interface on the owner if it needs to refuse a gaze.

KindNameSignatureDescription
varWidget ProgressbarProgressbarclass<WBP_Base>Indicator widget shown while the player dwells on this object. Choose the circular or linear variant, or subclass for your own.
varBuildup TimeProgressbarfloatSeconds the gaze has to be held before it fires. Tick Highlight opens a gated delay of this length while the gaze stays on the owner and raises Progress Finished when it elapses, so this is the number that decides when a gaze triggers. It is separate from Trigger Time, which the indicator is spawned with, and the two defaults are not the same.
varTrigger TimeProgressbarfloatHow long the player must keep looking at this object before it triggers, in seconds.
varSound ProgressbarSoundSoundBaseSound played while the dwell indicator fills.
fnCalculateLocationAndRotationDefault(Pawn: Pawn, Impact: Vector, out Location: Vector, out Rotation: Rotator)Works out where to place the dwell indicator and how to orient it towards the player.
fnCanGazeHighlight(HitComponent: PrimitiveComponent, SourceInfo: ST_SourceInfo, out CanHighlight: bool)Returns whether this object currently accepts gaze, consulting Interface Gaze on the owner if it is implemented.
eventTickHighlight(SourceInfo: ST_SourceInfo, TraceResult: HitResult)Keeps the gaze alive for this frame and advances the dwell timer. Triggers once Trigger Time is reached.
eventProgressFinished()Fires when the dwell completes. Bind to this to run the gaze action.
BPC_PawnAbility_Gaze1 members
extends BPC_PawnAbility

Pawn ability letting a pawn work things by looking at them. Each tick it reads the pawn's latest trace and, where the hit actor carries a gaze interaction willing to be gazed at, keeps that interaction's highlight alive and puts the pawn into the gaze interaction state. Add it to a pawn to grant gaze; it needs the pawn to answer the trace interface.

KindNameSignatureDescription
varGaze View DistanceSettingsfloatHow far the gaze trace reaches from the camera.

Helper

BP_Helper_GazeIndicator7 members
extends Actor

Indicator actor showing how far a gaze has progressed: a widget component carrying the progress widget, a sound that rises with the fill, and a timeline run at the interaction's trigger time. The gaze interaction spawns and destroys one per gaze, so this is not an actor to place.

KindNameSignatureDescription
varProgress BarSettingsclass<WBP_Base>Widget class used to draw the dwell progress.
varProgress SoundContentSoundBaseSound played while the indicator fills.
varTimerSettingsfloatSeconds the indicator takes to fill. Written in as the indicator is spawned and read once at begin play, which starts the bar over that duration, so the class default of zero is never the value that is used.
varAction IconContentTextureIcon drawn in the middle of the indicator, handed in as it is spawned. The circular widget reads it while initialising and collapses its icon border when nothing is set, so leaving it empty simply shows the ring on its own.
eventPlayProgressBar(Duration: float)Starts filling the indicator over the given duration.
eventHideAndDestroy()Fades the indicator out and destroys it.
eventSetDesiredPosition(Transform: Transform)Stores the transform the indicator should be moving towards, which the gaze interaction supplies each frame as the gaze point shifts across the surface. Begin Play seeds it with the indicator's own spawn transform.

Interfaces

Interface_Gaze1 members
extends Interface

Contract an actor implements to decide for itself whether it may be gazed at. The gaze interaction asks Can Gaze View, passing itself and the source info, before starting the fill. Implement it on the owning actor when gazing depends on the actor's own state; without it, every gaze on an active interaction is allowed.

KindNameSignatureDescription
fnCanGazeViewGazeView(GazeComp: BPC_Interaction_Gaze, SourceInfo: ST_SourceInfo, out CanHighlight: bool)Implement on an actor to veto or allow gaze under your own conditions. Returning false suppresses the gaze highlight and dwell.

Widgets

WBP_Gaze_Circular2 members
extends WBP_Base

Circular gaze indicator: a radial progress material that sweeps round and brightens as the gaze fills. Progress Updated is called with the new value as the dwell advances, which is the only event a replacement has to implement. The default indicator; point a gaze interaction's progress bar at it unless a bar reads better.

KindNameSignatureDescription
eventWidgetElement_PostInitiateStyle()Called on every element once the entire tree has been initiated and themed. Implement it for set-up that needs the finished tree, such as measuring or reading the state of a sibling.
eventProgressUpdated_Event(NewProgress: float)Bound to the indicator's Progress Updated and pushes the new fraction into the circular progress bar. Nothing else happens here, which is why a design of your own only has to answer this one event.
WBP_Gaze_Linear2 members
extends WBP_Base

Gaze indicator drawn as a horizontal bar rather than a ring, filling as the gaze progresses. Set it as a gaze interaction's progress bar where a bar suits the design better than a circle; it implements the same Progress Updated event as the circular one.

KindNameSignatureDescription
eventWidgetElement_PostInitiateStyle()Called on every element once the entire tree has been initiated and themed. Implement it for set-up that needs the finished tree, such as measuring or reading the state of a sibling.
eventProgressUpdated_Event(NewProgress: float)Bound to the indicator's Progress Updated and pushes the new fraction into the horizontal progress bar. Nothing else happens here, which is why a design of your own only has to answer this one event.