In this lesson, you will learn how to leverage Gameplay Tag Containers to enforce strict execution rules that prevent abilities from firing during specific character states, such as being knocked back or stunned.
The Logic of Blocking
In the Gameplay Ability System (GAS), every UGameplayAbility possesses two crucial configuration members: AbilityBlockTags and ActivationBlockedTags. While it might seem like just a technical detail, this is the primary mechanism for state-driven combat control.
When you define ActivationBlockedTags on an ability, the system performs a check against the owner's AbilitySystemComponent (ASC) tags before the ability starts. If the owner possesses any tag that exists within the ability's block container, the ability is effectively locked out.
Practical Implementation
Imagine a "Heavy Swing" ability that you want to disable if the player is currently under a "State.Debuff.Knockback" effect. Instead of writing complex if statements in your ability's CanActivateAbility logic, you simply configure the containers in the class constructor or within the Blueprint editor:
UYourAbility::UYourAbility()
{
// Define the tags that, if present on the ASC, will stop this ability from firing
ActivationBlockedTags.AddTag(FGameplayTag::RequestGameplayTag(FName("State.Debuff.Knockback")));
ActivationBlockedTags.AddTag(FGameplayTag::RequestGameplayTag(FName("State.Environment.Hazard")));
}
By using containers, you keep your ability logic clean and declarative. If an environmental hazard adds the State.Environment.Hazard tag to your character, the AbilitySystemComponent automatically evaluates all active abilities. Any ability containing that tag in its ActivationBlockedTags container will fail its activation check instantly, preventing the player from performing actions while they are, for instance, drowning or standing in fire.
This approach is highly performant because the AbilitySystemComponent caches these relationships. It offloads the responsibility of "can I do this?" from your custom code to the robust, data-driven framework of GAS, ensuring that your state management remains consistent across networked multiplayer sessions.
Key Takeaway: Use the ActivationBlockedTags container to declaratively define which status tags must be absent for an ability to execute, offloading state-based validation from your code to the engine's built-in tag-matching system.