Input Reactor
Categories:
Input reactor components sit on the unit entity and listen to InputDataNotificationBus. They are the unit-side response layer that turns stored input state into game actions — movement vectors, ability triggers, UI navigation, etc.
For usage guides and setup examples, see The Basics: GS_Unit.

Contents
How It Works
Each reactor declares which event names it cares about (inputReactEvents). When InputDataNotificationBus::InputStateChanged fires, the reactor compares the incoming stateName against its list. If it matches, it compares the new value against the previously stored value and calls the correct virtual method:
- 0 → non-zero →
HandlePressed - non-zero → non-zero →
HandleHeld - non-zero → 0 →
HandleReleased - any change →
HandleAxisChanged(axis variant only)
Reactors store lastInputValues per event name to track zero-crossings between frames.
Base Classes
GS_InputReactorComponent
Base class for discrete button/key input. Extend this to react to named input events with press, hold, and release semantics.
Virtual methods to override:
| Method | Parameters | Description |
|---|---|---|
HandlePressed | AZStd::string stateName | Called when the event value crosses from 0 to non-zero. |
HandleHeld | AZStd::string stateName | Called each frame while the event value remains non-zero. |
HandleReleased | AZStd::string stateName | Called when the event value crosses from non-zero to 0. |
Fields:
| Field | Description |
|---|---|
inputReactEvents | List of event name strings this reactor listens for |
lastInputValues | Map of {eventName → float} tracking previous values for zero-crossing detection |
GS_InputAxisReactorComponent
Base class for analogue axis input. Extend this for joystick, trigger, or any continuous value that should not use pressed/held/released semantics.
Virtual methods to override:
| Method | Parameters | Description |
|---|---|---|
HandleAxisChanged | AZStd::string stateName, float value | Called whenever the axis value changes. |
Concrete Reactors
KeyboardMovement_InputReactorComponent
Converts four discrete directional key events into a 2D movement axis. Maps moveUp/moveDown/moveLeft/moveRight to +1/-1 contributions on the X and Y axes. On any key press or release, recomputes the combined axis and calls MoverContextRequestBus::SetMoveInputAxis("x"/"y", value) on the unit.
| Field | Description |
|---|---|
moveUpEvent | Event name for the forward/up key |
moveDownEvent | Event name for the back/down key |
moveLeftEvent | Event name for the left key |
moveRightEvent | Event name for the right key |
Internal accumulation fields:
| Field | Description |
|---|---|
xAxisPositive / xAxisNegative | Accumulated +X and -X contributions |
yAxisPositive / yAxisNegative | Accumulated +Y and -Y contributions |
JoyAxisMovement_AxisReactorComponent
Directly maps two joystick axis event names to the Mover Context X and Y movement axes. Calls MoverContextRequestBus::SetMoveInputAxis("x"/"y", value) directly from HandleAxisChanged.
| Field | Description |
|---|---|
xAxisName | Input event name for the horizontal axis |
yAxisName | Input event name for the vertical axis |
API Reference
Reactors themselves do not expose a request bus. They consume InputDataNotificationBus and produce calls to MoverContextRequestBus or other action buses.
InputDataNotificationBus (consumed)
| Event | Description |
|---|---|
InputStateChanged(stateName, value) | Triggers zero-crossing comparison and calls HandlePressed/HandleHeld/HandleReleased/HandleAxisChanged. |
ClearInput() | Resets all lastInputValues to zero, triggering releases for any held inputs. |
MoverContextRequestBus (produced by movement reactors)
| Call | Description |
|---|---|
SetMoveInputAxis("x", value) | Sets the horizontal axis input (−1 to 1) on the unit’s MoverContext. |
SetMoveInputAxis("y", value) | Sets the vertical axis input (−1 to 1) on the unit’s MoverContext. |
Extension Guide
Use the InputReactor ClassWizard template to generate a new input reactor with boilerplate already in place — see GS_Unit Templates.
Create custom reactor components by extending GS_InputReactorComponent or GS_InputAxisReactorComponent.
#pragma once
#include <GS_Unit/InputData/GS_InputReactorComponent.h>
namespace MyProject
{
class AbilityInputReactor : public GS_Unit::GS_InputReactorComponent
{
public:
AZ_COMPONENT_DECL(AbilityInputReactor);
static void Reflect(AZ::ReflectContext* context);
protected:
void HandlePressed(const AZStd::string& stateName) override;
void HandleReleased(const AZStd::string& stateName) override;
};
}
In Reflect(), add the event names you want to listen to:
// In your component's activation or reflection, populate inputReactEvents:
inputReactEvents.push_back("ability_primary");
inputReactEvents.push_back("ability_secondary");
See Also
- Input Data — The full input pipeline overview
- Player Input Reader — Controller-side input reading
- Mover Context — Receives axis input from reactor components
Get GS_Unit
GS_Unit — Explore this gem on the product page and add it to your project.