Course contentsShow
← Unreal Engine Game Development
Lesson 667 of 8809. Gameplay Ability System (GAS)Free lesson

Canceling Abilities via Gameplay Tags

Design systems that automatically cancel active abilities when conflicting Gameplay Tags are applied to the character.

In this lesson, you will learn how to architect your Gameplay Ability System so that specific abilities automatically terminate when conflicting Gameplay Tags are applied to your character.

The Logic of Self-Cancellation

In complex games, you often have "mutually exclusive" actions. For example, if a player is performing a "Channeling Heal," they shouldn't be able to move or sprint. Instead of writing manual logic to check these conditions inside every ability, GAS provides a declarative way to handle this via the AbilityTagRequirements struct within your UGameplayAbility definition.

Configuring Cancellation

Every UGameplayAbility has two primary fields that dictate its lifecycle regarding tags:

  1. CancelAbilitiesWithTag: If an ability is activated, any active abilities that possess these tags will be canceled immediately.
  2. BlockAbilitiesWithTag: If an ability is active, any attempt to activate an ability with these tags will fail.

To set this up, you modify your Ability’s Blueprint (or C++ constructor). For instance, if you have a State.Stunned tag, you want your Ability.Sprint to cancel itself if that tag is applied.

In C++, you would configure this within the ability’s constructor:

// Within your UGameplayAbility subclass
USprintAbility::USprintAbility()
{
    // If the character becomes Stunned, this ability ends immediately
    CancelAbilitiesWithTag.AddTag(FGameplayTag::RequestGameplayTag(FName("State.Stunned")));
    
    // While Sprinting, prevent other movement abilities from triggering
    BlockAbilitiesWithTag.AddTag(FGameplayTag::RequestGameplayTag(FName("Ability.Dash")));
}

Why This Matters

By utilizing these tag-based filters, you decouple your ability logic from state management. You don’t need to manually check if (IsStunned) inside your ability’s ActivateAbility logic or tick. When a GameplayEffect applies the State.Stunned tag to your AbilitySystemComponent, the component automatically iterates through its active abilities, checks their CancelAbilitiesWithTag requirements, and invokes CancelAbility() on those that match. This keeps your code clean, performant, and much easier to debug when your ability list grows into the dozens.

Key Takeaway: Use the CancelAbilitiesWithTag and BlockAbilitiesWithTag fields in your Gameplay Ability settings to offload state-based cancellation logic to the engine, ensuring your abilities remain mutually exclusive without manual conditional checks.