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

Return to the regular view of this page.

Trigger Sensors

Trigger sensor component and sensor types — condition evaluation objects for physics, interact, and record-based world trigger activation.

TriggerSensorComponent is the condition container of the World Trigger system. It owns arrays of TriggerSensorType objects that define evaluation logic — collisions, interactions, record checks. When conditions pass, it fires WorldTriggerRequestBus::Trigger on the same entity.

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


Container Component

TriggerSensorComponent

Trigger Sensor component in the O3DE Inspector

Owns and evaluates all sensor type objects. Not subclassed — extended by adding TriggerSensorType objects to its arrays.

Bus: TriggerSensorRequestBus (ById, Single)

FieldTypeDescription
andConditionsvector<TriggerSensorType*>All types must pass for the trigger to fire.
orConditionsvector<TriggerSensorType*>Any type passing is sufficient to fire.
MethodReturnsDescription
DoActionvoidEvaluates all conditions. On pass, fires WorldTriggerRequestBus::Trigger and TriggerSensorNotificationBus::OnTriggered.
DoResetActionvoidEvaluates reset conditions and fires reset if they pass.

On Activate, automatically activates a PhysicsTriggerComponent on the entity if any sensor type returns true from NeedsPhysicsTrigger().


Base Type Class

TriggerSensorType

Abstract base for all sensor evaluation logic. Not a component — reflected manually in GS_InteractionSystemComponent::Reflect(). Subclass this to add new condition types.

VirtualReturnsDescription
Activate(entityId)voidCalled when the owning component activates. Connect to buses here.
Deactivate()voidCalled when the owning component deactivates. Disconnect from buses here.
EvaluateAction()boolReturns true if the condition is currently satisfied.
EvaluateResetAction()boolReturns true if the reset condition is satisfied. Returns true by default.
NeedsPhysicsTrigger()boolReturn true to signal that a PhysicsTriggerComponent should be activated. Returns false by default.
OnTriggerEnter(entity)voidCalled by the physics trigger when an entity enters the volume.
OnTriggerExit(entity)voidCalled by the physics trigger when an entity exits the volume.

Stores m_ownerEntityId for calling back to TriggerSensorRequestBus::DoAction() or DoResetAction() from event-driven types.


Built-in Sensor Types

SensorType_Collider

Physics overlap sensor. Returns NeedsPhysicsTrigger() = true, causing the owning component to activate a PhysicsTriggerComponent.

  • OnTriggerEnter stores the entering entity.
  • OnTriggerExit clears the stored entity.
  • EvaluateAction() returns true while a valid entity is present.
  • EvaluateResetAction() returns true when no entity is present.

SensorType_Record

Fires when a named save record changes to a configured value. Extends RecordKeeperNotificationBus — connects on Activate and fires DoAction automatically when the matching record changes.

  • EvaluateAction() calls GetRecord and compares against recordValue.

→ Record Sensor Type Reference

FieldDescription
recordNameName of the record to watch.
recordValueValue the record must reach to fire.

SensorType_Interact

Fires when any unit interacts with this entity via the targeting system. Extends InteractTriggerSensorRequestBus.

  • On interact: stores lastCaller and calls DoAction.
  • EvaluateAction() returns true while lastCaller is a valid entity.

SensorType_PlayerInteract

Player-only variant of SensorType_Interact. Extends SensorType_Interact and adds a tag check — lastCaller must have the "Player" tag for the condition to pass.


Extension Guide

To create a custom sensor type:

  1. Create a class extending TriggerSensorType.
  2. Override EvaluateAction() to define when your condition is satisfied.
  3. Override Activate(entityId) / Deactivate() to connect and disconnect from any buses.
  4. For event-driven evaluation, listen on a bus and call TriggerSensorRequestBus::DoAction(m_ownerEntityId) when the event fires — the component will run the full evaluation pipeline.
  5. Return true from NeedsPhysicsTrigger() if your type needs a physics volume.
  6. Reflect the class in GS_InteractionSystemComponent::Reflect() — types are not components and are not registered via CreateDescriptor().

See Also


Get GS_Interaction

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

1 - SensorType_Record

Record-based sensor type — fires when a named RecordKeeper entry reaches a configured value.

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


Overview

SensorType_Record is a TriggerSensorType that fires when a named save record is changed to a configured value. Add it to the andConditions or orConditions array on a TriggerSensorComponent.

Inherits from RecordKeeperNotificationBus — connects automatically on Activate and listens for record changes without polling. When a matching record change arrives, it calls TriggerSensorRequestBus::DoAction on the owning component, which runs the full condition evaluation pipeline.


Fields

FieldTypeDescription
recordNamestringName of the record to watch in the RecordKeeper.
recordValueintValue the record must reach for the condition to pass.

Evaluation

EvaluateAction() calls RecordKeeperRequestBus::GetRecord(recordName) and compares the result to recordValue. Returns true if they match.

The type self-triggers on record change events — you do not need to poll or script a check manually.


Setup

  1. Add a TriggerSensorComponent to your entity.
  2. Add a SensorType_Record entry to the andConditions or orConditions array.
  3. Set recordName to the record you want to watch.
  4. Set recordValue to the value that should fire the trigger.
  5. Add a WorldTriggerComponent with the desired WorldTriggerType objects to the same entity.

API

From TriggerSensorType:

//! Returns true if the watched record currently matches recordValue.
virtual bool EvaluateAction();

//! Connects to RecordKeeperNotificationBus on component activate.
virtual void Activate(AZ::EntityId entityId);

//! Disconnects from RecordKeeperNotificationBus on component deactivate.
virtual void Deactivate();

From RecordKeeperNotificationBus:

//! Called when any record changes. Fires DoAction if recordName and recordValue match.
virtual void RecordChanged(const AZStd::string& name, int value);

Get GS_Interaction

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