Mover Context

The central movement hub — transforms raw input into camera-relative and ground-projected vectors, manages mode switching, context states, and movement profiles.

GS_MoverContextComponent is the central state store for all movement on a unit. It sits between the input layer and the mover/grounder layer, holds all shared movement data, owns the mode-switching logic, and manages the active movement profile.

Movers and Grounders never communicate directly — they all read from and write to the MoverContext.

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

Mover Context component in the O3DE Inspector

 

Contents


Input Transformation Pipeline

Raw input from reactor components arrives as a Vector2 (rawMoveInput). The MoverContext applies two sequential transformations each time input changes.

Step 1 — ModifyInputAxis() — Camera-Relative

For a player unit (detected by “Player” tag): fetches the active camera’s world transform, flattens its forward and right vectors to the XY plane, then computes:

modifiedMoveInput = camForward * rawInput.Y + camRight * rawInput.X

For AI units (or when inputOverride = true): uses world cardinal axes (Y=forward, X=right).

Step 2 — GroundInputAxis() — Ground-Projected

Projects modifiedMoveInput onto the ground plane using the current groundNormal:

groundedMoveInput = modifiedMoveInput - groundNormal * dot(modifiedMoveInput, groundNormal)

Direction is then normalized and the original magnitude is restored. Movers use groundedMoveInput so movement always follows the surface contour, even on slopes.

Both steps run automatically whenever SetMoveInputAxis is called and again whenever SetGroundNormal is called (ground changed under a moving unit).


Mode Switching

The MoverContext maintains three independent mode strings, each with a current and last value:

Mode TypeCurrentLast
Movement modecurrentMoveModelastMoveMode
Rotation modecurrentRotateModelastRotateMode
Grounding modecurrentGroundingModelastGroundingMode

ChangeMovementMode("Free") updates the string and broadcasts MoverContextNotificationBus::MovementModeChanged("Free"). Each Mover and Grounder component checks whether its own named mode matches the broadcast and activates or deactivates itself accordingly.

RevertToLastMovementMode() swaps current and last — enabling one-step undo (e.g., return from “Slide” to whatever was active before).


Context States

A generic key-value store for runtime state flags used by movers and grounders:

AZStd::unordered_map<AZStd::string, AZ::u32> contextStates

SetContextState(name, value) writes and broadcasts MoverContextNotificationBus::ContextStateChanged.

Known state keys:

KeySet byValuesMeaning
"grounding"PhysicsRayGrounder0 = Falling, 1 = Grounded, 2 = SlidingGround contact state
"StopMovement"Various1 = stopSignals the Free Mover to zero velocity

Movement Profile Management

The MoverContext selects the active GS_UnitMovementProfile* by priority:

  1. Influence listAddMovementProfile(influencer, profile*) is called by MovementInfluenceFieldComponent when the unit enters a trigger volume. Multiple fields stack additively by priority via MovementInfluenceRequestBus::GetPriority.
  2. Global fallback — if influenceList is empty and allowGlobalInfluence is true, checks GlobalMovementRequestBus::GetGlobalMovementProfile.
  3. Default profile — the asset-configured defaultMoveProfile on the component.

When the profile changes, MoverContextNotificationBus::MovementProfileChanged(profile*) is broadcast. Movers update their cached activeProfile pointer.

Standby behavior:

  • UnitEnteringStandby → clears the influence list, broadcasts empty mode names (disables all movers/grounders)
  • UnitExitingStandby → re-evaluates profile priority, re-broadcasts current mode names to re-enable the correct movers

Editor-Exposed Fields

FieldDescription
defaultMoveProfileAsset reference to the fallback GS_UnitMovementProfile
allowGlobalInfluenceWhether to accept the global movement profile as a fallback
startingMoveModeMode name to broadcast on activate (one-frame delayed to allow all components to start first)
startingRotateModeRotation mode name to start with
startingGroundingModeGrounding mode name to start with
maxWalkDegreesSlope angle (degrees) above which movement is no longer considered grounded

API Reference

Request Bus: MoverContextRequestBus

Commands sent to a specific unit’s MoverContext. ById bus — addressed by unit entity ID.

Input Axis:

MethodParametersReturnsDescription
SetMoveInputAxisAZStd::string axisName, float axisValuevoidSets the raw input on “x” or “y”. Triggers ModifyInputAxis() and GroundInputAxis(). Clamps total magnitude to 1.0.
GetMoveInputAxisAZ::Vector2*Returns pointer to rawMoveInput.
GetModifiedMoveInputAxisAZ::Vector3*Returns pointer to camera-relative modifiedMoveInput.
GetGroundMoveInputAxisAZ::Vector3*Returns pointer to ground-projected groundedMoveInput.

Ground State:

MethodParametersReturnsDescription
SetGroundNormalAZ::Vector3 newNormalvoidUpdates the ground normal and re-projects modifiedMoveInput.
GetGroundNormalAZ::Vector3*Returns pointer to current ground normal.
GetSlopeDirectionAZ::Vector3*Returns pointer to the current slope direction vector.
GetSlopeAnglefloat*Returns pointer to the current slope angle (dot product with up).
GetMaxWalkAnglefloat*Returns pointer to the cosine of maxWalkDegrees.

Context States:

MethodParametersReturnsDescription
SetContextStateAZStd::string stateName, AZ::u32 stateValuevoidWrites a state value and broadcasts ContextStateChanged.
GetContextStateAZStd::string stateNameAZ::u32Returns the current value for the named state.

Mode Switching:

MethodParametersReturnsDescription
ChangeMovementModeAZStd::string targetMoveModevoidSets current move mode and broadcasts MovementModeChanged.
RevertToLastMovementModevoidSwaps current and last move mode.
ChangeRotationModeAZStd::string targetRotateModevoidSets current rotation mode and broadcasts RotationModeChanged.
RevertToLastRotationModevoidSwaps current and last rotation mode.
ChangeGroundingModeAZStd::string targetGroundingModevoidSets current grounding mode and broadcasts GroundingModeChanged.
RevertToLastGroundingModevoidSwaps current and last grounding mode.

Profile Management:

MethodParametersReturnsDescription
AddMovementProfileAZ::EntityId influencer, GS_UnitMovementProfile* profilevoidAdds an influence-field profile to the priority list and re-evaluates.
RemoveMovementProfileAZ::EntityId influencervoidRemoves an influence-field profile and re-evaluates.

Notification Bus: MoverContextNotificationBus

Events broadcast by the MoverContext. ById bus — addressed by unit entity ID. Movers and Grounders subscribe to this.

EventParametersDescription
MovementModeChangedAZStd::string modeNameFired when the movement mode changes. Movers activate or deactivate based on their m_moveModeName.
RotationModeChangedAZStd::string modeNameFired when the rotation mode changes.
GroundingModeChangedAZStd::string modeNameFired when the grounding mode changes. Grounders activate or deactivate based on their m_groundModeName.
ContextStateChangedAZStd::string stateName, AZ::u32 valueFired when a context state value changes.
MovementProfileChangedGS_UnitMovementProfile* profileFired when the active movement profile is replaced. Movers update their activeProfile pointer.

Virtual Methods

Override these when extending the MoverContext.

MethodDescription
ModifyInputAxis()Transforms rawMoveInput into modifiedMoveInput (camera-relative). Override for custom camera or axis mapping.
GroundInputAxis()Projects modifiedMoveInput onto the ground plane into groundedMoveInput. Override for custom surface projection.

Script Canvas Examples

Changing movement mode:

Reverting to the previous movement mode:

Setting a context state flag:


See Also

  • Movers — Mover components that read from the MoverContext
  • Grounders — Grounder components that write ground state to the MoverContext
  • Movement — Movement system overview
  • Input Data — The input pipeline that feeds SetMoveInputAxis

Get GS_Unit

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