Targeting Handler

Central targeting processor — receives target registrations from sensory fields, selects best interact target, and manages cursor feedback.

The GS_TargetingHandlerComponent is the central processor for the targeting system. It receives target registrations from sensory fields, maintains categorized lists of detected targets, and selects the best interact target based on proximity and type. It also manages cursor feedback and interaction range tracking.

For usage guides and setup examples, see The Basics: GS_Interaction.


The Targeting Handler sits on the same entity as the unit it serves (typically the player or an AI character). Sensory fields register and unregister targets as they enter and exit detection volumes. The handler evaluates all registered targets each tick to determine the closest interactable, which becomes the active interact target.

 

Contents


How It Works

Target Selection

Each tick, the handler runs ProcessClosestInteractable to evaluate all registered targets. It filters by type, checks interaction range, and selects the closest valid target. The result is broadcast via OnUpdateInteractTarget.

Interaction Range

A separate interaction range field provides a close-proximity subset of targets. Targets within this range are prioritized for interact selection. The range is driven by a dedicated GS_TargetingInteractionFieldComponent trigger volume.

Cursor Tracking

The handler updates the cursor position to follow the active interact target. Cursor visuals change based on target type (interact, item, unit, etc.).


API Reference

GS_TargetingHandlerRequestBus

Bus policy: ById, Multiple

MethodParametersReturnsDescription
RegisterTargetAZ::EntityId entityboolRegisters a target entity detected by a sensory field.
UnregisterTargetAZ::EntityId entityboolRemoves a target entity from the detection list.
RegisterInteractionRangeTargetAZ::EntityId entityboolRegisters a target within the close interaction range.
UnregisterInteractionRangeTargetAZ::EntityId entityboolRemoves a target from the interaction range list.
GetInteractTargetAZ::EntityIdReturns the current best interact target.

GS_TargetingHandlerNotificationBus

Bus policy: ById, Multiple

EventParametersDescription
OnUpdateInteractTargetAZ::EntityId targetFired when the active interact target changes.
OnEnterStandbyFired when the system enters standby mode.
OnExitStandbyFired when the system exits standby mode.

Virtual Methods

MethodParametersReturnsDescription
CheckForTickvoidCalled each tick to evaluate whether target processing should run.
ProcessClosestInteractablevoidDetermines the closest interactable target and sets it as the active interact target.

GS_CursorComponent

Manages cursor display and positioning for targeting feedback.

GS_CursorRequestBus

Bus policy: Single, Multiple

MethodParametersReturnsDescription
RegisterCursorCanvasAZ::EntityId canvasvoidRegisters the UI canvas for cursor rendering.
HideCursorbool hidevoidShows or hides the cursor.
SetCursorOffsetAZ::Vector2 offsetvoidSets the screen-space offset for cursor positioning.
SetCursorVisualsvisual datavoidConfigures cursor appearance.
SetCursorPositionAZ::Vector2 posvoidSets the cursor screen position directly.

GS_CursorCanvasComponent

UI canvas layer that renders the cursor sprite.

GS_CursorCanvasRequestBus

Bus policy: ById, Multiple

MethodParametersReturnsDescription
HideSpritebool hidevoidShows or hides the cursor sprite element.
SetCursorSpritesprite datavoidSets the cursor sprite image.

Extension Guide

The Targeting Handler is designed for extension via companion components. Add custom targeting logic by creating components that listen to GS_TargetingHandlerNotificationBus on the same entity. Override ProcessClosestInteractable for custom target selection algorithms.


Script Canvas Examples

Getting the current interact target:

Reacting to interact target changes:


See Also

For conceptual overviews and usage guides:

For component references:


Get GS_Interaction

GS_Interaction — Explore this gem on the product page and add it to your project.