Skip to content

MotionAbilitySystemHelper

Helper functions for integrating Motion with Unreal's Gameplay Ability System (GAS). Provides utilities for input binding, ASC lookup/initialization, gameplay tags, effect-based tag application, and universal attribute discovery.

Functionality

ASC Discovery

FunctionDescription
GetEnhancedInputComponentFromActor(Actor, bLogErrors=false)Returns the actor's UEnhancedInputComponent, or nullptr if not found.
GetAbilitySystemComponentFromActor(Actor, bLogErrors=false)Finds an UAbilitySystemComponent via IAbilitySystemInterface on the Actor or its PlayerState.

Attribute Discovery (New in Preview 3)

These functions enable Motion to work with ANY AttributeSet by discovering attributes by name:

FunctionDescription
FindAttributeByName(ASC, AttributeName)Searches all AttributeSets on the ASC for an attribute with the given name. Returns an FGameplayAttribute (invalid if not found).
GetAttributeValueByName(ASC, AttributeName, OutValue)Gets the current value of an attribute by name. Returns true if found.
SetAttributeValueByName(ASC, AttributeName, NewValue)Sets the base value of an attribute by name. Returns true if found.
HasAttributeByName(ASC, AttributeName)Checks if an attribute with the given name exists on the ASC.

Example Usage

cpp
// Find any attribute by name - works with ANY AttributeSet
FGameplayAttribute WalkSpeedAttr = UMotionAbilitySystemHelper::FindAttributeByName(ASC, "WalkSpeed");
if (WalkSpeedAttr.IsValid())
{
    float Value = ASC->GetNumericAttribute(WalkSpeedAttr);
}

// Get/Set values directly by name
float CurrentStamina;
if (UMotionAbilitySystemHelper::GetAttributeValueByName(ASC, "Stamina", CurrentStamina))
{
    // Use the stamina value
}

// Check if an attribute exists before using it
if (UMotionAbilitySystemHelper::HasAttributeByName(ASC, "JumpVelocity"))
{
    // Jump velocity attribute is available
}

Gameplay Tags

FunctionDescription
ActorHasGameplayTag(Actor, Tag)Checks whether the actor's ASC has the specified gameplay tag.
AddGameplayTagToActor(Actor, Tag)Adds a loose gameplay tag to the actor's ASC.
RemoveGameplayTagFromActor(Actor, Tag)Removes a loose gameplay tag from the actor's ASC.
ApplyGameplayTagEffect(Actor, EffectClass)Applies a UGameplayEffect that grants tags; returns an active effect handle.
RemoveGameplayTagEffect(Actor, EffectHandle)Removes a previously applied tag‑granting effect by handle.
ApplyTagEffectFromClass(Actor, EffectClass, FallbackTag)Applies EffectClass, or falls back to adding FallbackTag as a loose tag.
RemoveTagEffectWithFallback(Actor, EffectHandle, FallbackTag)Removes tag effect and its fallback loose tag (idempotent). Handles asymmetry where ApplyTagEffectFromClass may have applied via GE or loose tag.

ASC Initialization

FunctionDescription
InitializeCharacterAbilitySystem(Character, bLogErrors=true)Initializes ASC owner/avatar bindings for a character.
InitializeCharacterAbilitySystemWithAttributeSet(Character, AttributeSetClass, bLogErrors=true, AttributeDataTable=nullptr, bLogDataTableDetails=false)Initializes ASC and ensures an UAttributeSet exists; optionally initializes values from a DataTable.
InitializeAttributeSetFromDataTable(ASC, AttributeDataTable, AttributeSetClass=nullptr, bLogDetails=false)Calls InitFromMetaDataTable on one or all AttributeSets in the ASC.

Movement Helpers

FunctionDescription
GetPlatformRelativeVelocity(CMC)Returns the character's velocity relative to any moving platform they're standing on. Subtracts platform velocity for accurate locomotion calculations.
GetPlatformRelativeSpeed(CMC)Returns the magnitude of platform-relative velocity. Convenience wrapper around GetPlatformRelativeVelocity.

Motion - Advanced First Person Character Controller