Gameplay Ability System (GAS) Overview
⚔️ Gameplay Ability System (GAS) Overview in Unreal Engine 5
The Gameplay Ability System (GAS) is Epic Games' modular framework for RPGs, hero shooters, and action combat. It standardizes character Attributes (Health, Mana), Abilities (Spells, Attacks), Gameplay Effects (Buffs, Damage), and Gameplay Tags.
🏛️ The Four Core Components of GAS
+-------------------------------------------------------------+
| 1. Ability System Component (ASC) (`UAbilitySystemComponent`)|
| - Heart of the system: handles granting, activation, net |
+-------------------------------------------------------------+
│ │ │
▼ ▼ ▼
+------------------+ +------------------+ +------------------+
| AttributeSet | | GameplayEffect | | GameplayAbility |
| (HP, Stamina) | | (Damage, Buffs) | | (Melee, Dash) |
+------------------+ +------------------+ +------------------+
🏷️ 1. Gameplay Tags (The Hierarchical Enum)
Gameplay Tags (FGameplayTag) replace messy booleans (bool bIsStunned, bool bIsAttacking) with hierarchical identifiers:
State.Debuff.StunAbility.Melee.HeavySlashEvent.Combat.HitReaction
An ability can declare Trigger Tags (activates when tag added), Blocked Tags (cannot cast if State.Debuff.Silence exists), and Cancel Tags.
💻 2. Defining an AttributeSet in C++
#pragma once
#include "CoreMinimal.h"
#include "AttributeSet.h"
#include "AbilitySystemComponent.h"
#include "MyAttributeSet.generated.h"
#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
UCLASS()
class MYPROJECT_API UMyAttributeSet : public UAttributeSet
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadOnly, Category = "Attributes", ReplicatedUsing = OnRep_Health)
FGameplayAttributeData Health;
ATTRIBUTE_ACCESSORS(UMyAttributeSet, Health)
UFUNCTION()
virtual void OnRep_Health(const FGameplayAttributeData& OldHealth);
virtual void PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) override;
virtual void PostGameplayEffectExecute(const FGameplayEffectModCallbackData& Data) override;
};
🔗 Related Notes
- Index for Unreal — Unreal Engine implementation philosophy.
- Optimization — Profiling gameplay tags and actor memory.
- Basics Of NetWorking — Unreal replication and NetDriver channels.