Appearance
How to use GAS patterns with Motion
Use this guide when you understand Motion's GAS model and need to apply common implementation patterns.
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 replicated GameplayEffects for authoritative state. Use loose tags only for short-lived local prediction.
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);
ASC->ApplyGameplayEffectSpecToSelf(*Spec.Data.Get());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 authoritative gameplay decisions on the server.
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.
- Use blocked tags on the GameplayEffect when the state should prevent sprinting, crouching, or jumping.
For a broader recipe collection, see How to customize Motion movement behavior.