In this lesson, you will learn how to enforce state-based restrictions on your Gameplay Abilities using the Ability Tags, Cancel Abilities with Tag, and Block Abilities with Tag configuration settings.
Understanding Activation Requirements
When designing a robust Ability System, simply creating an ability isn't enough; you must define the "permission" context under which it can execute. GAS provides built-in containers within the UGameplayAbility class that automatically check these requirements before the ActivateAbility logic ever runs.
The Configuration Trio
Within your Ability Blueprint (or C++ constructor), you will find these three critical containers:
- Ability Tags: These act as the "identity" of the ability. They help the system categorize the ability (e.g.,
Ability.Skill.Fireball). - Cancel Abilities with Tag: If you trigger an ability with one of these tags, the current ability will be automatically aborted. This is perfect for interrupting a "Channeling" ability when the player triggers a "Dash" or "Dodge."
- Block Abilities with Tag: This is the gatekeeper. While this ability is active, any ability possessing a tag listed here will fail to trigger. This is essential for preventing state conflicts, such as preventing a "Jump" or "Attack" while the player is currently "Stunned."
Practical Implementation
Imagine you are creating a GA_Stunned ability that applies a State.Debuff.Stunned tag to your character. To ensure the player cannot cast spells while stunned, you would navigate to your offensive abilities (like GA_Fireball) and add State.Debuff.Stunned to the Block Abilities with Tag array.
// In your Ability constructor
AbilityTags.AddTag(FGameplayTag::RequestGameplayTag(FName("Ability.Skill.Fireball")));
// Block the ability if the player is stunned or dead
ActivationBlockedTags.AddTag(FGameplayTag::RequestGameplayTag(FName("State.Debuff.Stunned")));
ActivationBlockedTags.AddTag(FGameplayTag::RequestGameplayTag(FName("State.Dead")));
By leveraging these containers, you move the responsibility of state-checking out of your ActivateAbility logic and into the engine's internal activation flow, significantly reducing the amount of "if/else" logic required inside your ability graphs.
Key Takeaway: Use the Ability's built-in Tag containers to declaratively define state dependencies, ensuring that ability activation is automatically governed by your character's current Gameplay Tag status.