Appearance
How to use Gameplay Ability System patterns with Motion
Use this guide when you understand Motion's Gameplay Ability System (GAS) model and need to apply common implementation patterns.
Initialize the character Ability System Component (ASC)
Motion works best when the replicated ASC lives on PlayerState and the character initializes owner/avatar bindings after possession:
cpp
UMotionAbilitySystemHelper::InitializeCharacterAbilitySystem(Character, true);Create and initialize your custom AttributeSet in your ASC setup. If no UMotionAttributeSet exists, a Motion component creates that shipped set on the server after ASC initialization. For custom DataTable defaults, call Unreal's InitFromMetaDataTable on your AttributeSet with rows such as MotionAttributeSet.WalkSpeed.
Check state with tags
Use Motion helper functions when gameplay logic needs to branch on movement state:
cpp
const bool bIsSprinting = UMotionAbilitySystemHelper::ActorHasGameplayTag(
Character,
MotionGameplayTags::Motion_State_Sprinting
);Use server-applied GameplayEffects for replicated state. Use loose tags for predicted intent or locally derived presentation state, never as replicated truth.
Keep intent and active state separate. For example, Motion.State.WantsToSprint can be true while the character is idle, blocked, or out of stamina; Motion.State.Sprinting should only be true when sprinting is currently active. If you locally predict an active state tag for visual responsiveness, add a correction path for any server-side rejection.
When a component supports both paths, pair ApplyTagEffectFromClass with RemoveTagEffectWithFallback:
cpp
FActiveGameplayEffectHandle SprintingHandle =
UMotionAbilitySystemHelper::ApplyTagEffectFromClass(
Character,
SprintingTagEffect,
MotionGameplayTags::Motion_State_Sprinting
);
UMotionAbilitySystemHelper::RemoveTagEffectWithFallback(
Character,
SprintingHandle,
MotionGameplayTags::Motion_State_Sprinting
);On the server, a valid GameplayEffect handle represents replicated state. On a predicting client or failed effect path, the fallback loose tag is local and the handle can be invalid.
Apply a temporary speed modifier
- Create a GameplayEffect that modifies
WalkSpeed. - Choose
Durationwhen the modifier expires automatically, orInfinitewhen code removes it. - Apply the effect on the server:
cpp
FGameplayEffectContextHandle Context = ASC->MakeEffectContext();
FGameplayEffectSpecHandle Spec = ASC->MakeOutgoingSpec(SpeedBuffEffect, 1.0f, Context);
if (Spec.IsValid())
{
ASC->ApplyGameplayEffectSpecToSelf(*Spec.Data.Get());
}Before applying effects from component code, ensure the ASC is initialized. Attribute and modifier effects should be applied from initialized server code.
React to attribute changes
Bind to the ASC attribute delegate during component initialization:
cpp
ASC->GetGameplayAttributeValueChangeDelegate(
UMotionAttributeSet::GetStaminaAttribute()
).AddUObject(this, &UMyComponent::OnStaminaChanged);Keep UI, audio, and cosmetic reactions local. Keep gameplay decisions on the server.
Read and write attributes by name
Motion helpers and component-specific lookup paths can read custom AttributeSets when those sets expose the expected property names:
cpp
float CurrentStamina = 0.0f;
if (UMotionAbilitySystemHelper::GetAttributeValueByName(
ASC,
TEXT("Stamina"),
CurrentStamina))
{
// Use current stamina for UI or local gating.
}FindAttributeByName and GetAttributeValueByName are safe discovery helpers. For writes, use GameplayEffects for gameplay changes or SetNumericAttributeBase in explicit initialization code. To drive Motion movement from project attributes, retarget the profile GameplayEffects and provide equivalent synchronization to CharacterMovementComponent where the shipped UMotionAttributeSet normally owns it.
Configure custom movement states
- Define a project GameplayTag such as
Motion.State.Sliding. - Create a GameplayEffect that grants the tag.
- Map the tag to an Animation Blueprint property when animation needs it.
- Add explicit checks for the custom state in the Motion component conditions that should reject it. GameplayEffect application requirements only control whether that effect can apply; they do not make the built-in Motion components recognize a new blocking state automatically.
If the state has owner-visible animation or camera feedback, decide whether the owning client should predict the active state tag. Predicted tags must be scoped to the locally controlled character and removed when the server confirms, rejects, or replaces the state.
For a broader recipe collection, see How to customize Motion movement behavior.