Skip to content

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

  1. Create a GameplayEffect that modifies WalkSpeed.
  2. Choose Duration when the modifier expires automatically, or Infinite when code removes it.
  3. 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

  1. Define a project GameplayTag such as Motion.State.Sliding.
  2. Create a GameplayEffect that grants the tag.
  3. Map the tag to an Animation Blueprint property when animation needs it.
  4. 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.

Motion - Advanced First Person Character Controller