This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Targeting

Target detection, selection, and cursor management — scanning, filtering, and selecting entities based on proximity and sensory fields.

The targeting system provides spatial awareness and entity selection for units and other entities. A TargetingHandler component serves as the central processor — it receives target registrations from sensory fields, maintains categorized target lists, and selects the best interact target based on proximity and type filtering. The system supports a cursor overlay for visual feedback and an input reader for triggering interactions.

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

Targeting Handler component in the O3DE Inspector Targeting Interaction Field component in the O3DE Inspector Interact Cursor component in the O3DE Inspector Interact Target component in the O3DE Inspector

 

Contents


Components

ComponentPurpose
GS_TargetingHandlerComponentCentral targeting processor. Receives target registrations, selects best interact target.
GS_TargetingInteractionFieldComponentPhysics trigger volume for proximity-based target detection.
GS_TargetComponentBase target marker. Makes an entity detectable by the targeting system.
GS_InteractTargetComponentSpecialized interact target extending GS_TargetComponent.
GS_CursorComponentCursor display and positioning for targeting feedback.
GS_CursorCanvasComponentUI canvas layer for cursor sprite rendering.
InteractInputReaderComponentInput reader that bridges interact input to trigger actions on the current target.

EBus Summary

Request Buses

BusAddressHandlerKey Methods
GS_TargetingHandlerRequestBusByIdMultipleRegisterTarget, UnregisterTarget, RegisterInteractionRangeTarget, UnregisterInteractionRangeTarget, GetInteractTarget
GS_TargetRequestBusByIdMultipleGetTargetSize, GetTargetOffset, GetTargetColour, GetTargetSprite
GS_CursorRequestBusSingleMultipleRegisterCursorCanvas, HideCursor, SetCursorOffset, SetCursorVisuals, SetCursorPosition
GS_CursorCanvasRequestBusByIdMultipleHideSprite, SetCursorSprite

Notification Buses

BusAddressHandlerKey Events
GS_TargetingHandlerNotificationBusByIdMultipleOnUpdateInteractTarget, OnEnterStandby, OnExitStandby

See Also

For component references:

For related resources:


Get GS_Interaction

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

1 - 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.

2 - Senses & Targeting Fields

Physics-based detection volumes for the targeting system — interaction fields and sensory detection.

Targeting fields are physics-based detection volumes that feed target registrations into the Targeting Handler. The GS_TargetingInteractionFieldComponent provides proximity detection for interact-range targets. Fields use their own collision layers and should be placed on child entities rather than the main unit capsule.

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


GS_TargetingInteractionFieldComponent

A physics trigger volume that detects targets entering and exiting the interaction range. Extends AZ::Component and PhysicsTriggeringVolume. Registers detected entities with the parent Targeting Handler.

API

MethodParametersReturnsDescription
TriggerEnterAZ::EntityId entityboolCalled when an entity enters the field. Registers the entity as an interaction-range target.
TriggerExitAZ::EntityId entityboolCalled when an entity exits the field. Unregisters the entity from the interaction-range list.

Setup

  1. Create a child entity under the unit entity that owns the Targeting Handler.
  2. Add a PhysX collider configured as a trigger shape.
  3. Add the GS_TargetingInteractionFieldComponent.
  4. Set the collider to use a dedicated interaction collision layer — do not share the unit’s physics layer.
  5. Point the field to the parent Targeting Handler entity.

Extension Guide

Custom sensory fields can be created by extending the base field pattern:

  1. Create a component that extends AZ::Component and PhysicsTriggeringVolume.
  2. On trigger enter/exit, call RegisterTarget / UnregisterTarget on the Targeting Handler via GS_TargetingHandlerRequestBus.
  3. Add custom filtering logic (line of sight, tag filtering, team affiliation) in your trigger callbacks.

See Also


Get GS_Interaction

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

3 - Targets

Target component types — base target markers and specialized interact targets that make entities detectable by the targeting system.

Target components mark entities as detectable by the targeting system. The base GS_TargetComponent provides core target data (size, offset, visual properties). Specialized variants like GS_InteractTargetComponent add interaction-specific behavior.

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


GS_TargetComponent

Base target component. Makes an entity visible to the targeting system with configurable visual properties for cursor feedback.

GS_TargetRequestBus

Bus policy: ById, Multiple

MethodParametersReturnsDescription
GetTargetSizefloatReturns the target’s visual size for cursor scaling.
GetTargetOffsetAZ::Vector3Returns the world-space offset for cursor positioning above the target.
GetTargetColourAZ::ColorReturns the target’s highlight colour.
GetTargetSpritesprite refReturns the target’s cursor sprite override, if any.

GS_InteractTargetComponent

Extends GS_TargetComponent with interact-specific properties. Entities with this component can be selected as interact targets by the Targeting Handler and triggered via the Interact Input system.


Cross-Gem Target Types

Additional target types are conditionally compiled when GS_Interaction is available alongside other gems:

TypeSource GemConditionDescription
ItemTargetGS_Item#IF GS_INTERACTIONMakes item entities targetable for pickup and inspection.
UnitTargetGS_Unit#IF GS_INTERACTIONMakes unit entities targetable for interaction and AI awareness.

Extension Guide

Create custom target types by extending GS_TargetComponent:

  1. Create a new component class extending GS_TargetComponent.
  2. Override the target data methods (GetTargetSize, GetTargetOffset, etc.) to return your custom values.
  3. Add any additional data fields specific to your target type.
  4. The targeting system will automatically detect and categorize your custom targets when they enter sensory fields.

See Also


Get GS_Interaction

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

4 - Interact Input Reader

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

Image showing the InteractInputReader component, as seen in the Entity Inspector.

Interact Input Reader Overview

Extends Input Reader.

This component is a standalone input detector utility to enable Interact Input firing outside of the GS_Unit Gem.

It intakes the Event Name for your chosen interaction input, as defined in your Input Profile and ignores all other input.

Functionality

Interact Input Reader needs to be put in the same entity as the Targeting Handler.

After firing the correct Input Event, the Interact Input Reader requests the current InteractTarget from the Targeting Handler. It then sends a DoInteractAction event, with a reference to its EntityId as caller, to the InteractTriggerSensor component that should be present on the Interact Target.

The World Trigger and Trigger Sensor system takes care of the rest.


Setting Up Your Interact Input Reader

Assure that the component is placed on the same Entity as the Targeting Handler.

Image showing the Interact Input Reader Component alongside the Targeting Handler Component.

Fill the Interact Event Name with the Event Name for your chosen interaction input, as defined in your Input Profile.

So long as the Input Profile that’s set in your GS_OptionsManager has that event set. The rest should work as is.


API

// OptionsManagerNotificationBus
void HandleStartup() override;

// Local Methods (Parent Input Reader Component Class)
void HandleFireInput(AZStd::string eventName, float value) override;

Extending Interact Input Reader


Get GS_Interaction

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