Unreal Engine Gameplay Ability System (GAS) -- C++ Guide
Official Documentation (always consult for latest details)
These are the authoritative sources. Reference them for up-to-date API details, as GAS evolves across engine versions:
The community docs by tranek are the most comprehensive single resource for GAS. They cover advanced topics (prediction internals, optimization, replication modes, pitfalls) that Epic's official docs do not. Always check them for edge cases and production patterns.
The Lyra Sample Project is Epic's recommended working reference implementation for GAS.
Plugin Setup
- Enable Gameplay Abilities plugin in the editor
- Add to
Build.cs:PublicDependencyModuleNames.AddRange(new string[] {
"GameplayAbilities", "GameplayTags", "GameplayTasks"
});
- UE 5.2 and earlier: call
UAbilitySystemGlobals::Get().InitGlobalData() in your AssetManager or GameInstance. UE 5.3+ does this automatically.
Core Architecture
See references/core-classes.md for the full class reference, setup patterns, and C++ code snippets.
System overview:
Actor
+-- UAbilitySystemComponent (ASC) --- manages everything below
+-- UGameplayAbility instances (granted abilities)
| +-- UAbilityTask instances (async execution)
+-- UAttributeSet instances (numeric data)
+-- Active UGameplayEffect specs (modifiers)
+-- FGameplayTag container (status/state)
+-- GameplayCue triggers (cosmetic FX)
Key relationships:
- ASC is the central hub; one per Actor (place on Pawn or PlayerState)
- Abilities create/apply Effects to modify Attributes and Tags on targets
- Effects auto-trigger Cues when their tags match
GameplayCue.* tags
- Tags control ability activation, blocking, and cancellation systemically
- AbilityTasks handle async work (montages, delays, targeting) within abilities
Gameplay Effects Quick Reference
See references/effects-and-attributes.md for detailed GE patterns, modifier math, stacking, cooldowns, and attribute handling.
Duration types:
- Instant -- modifies BaseValue permanently, never tracked as active
- Duration -- modifies CurrentValue, auto-reverts on expiry
- Infinite -- persists until explicitly removed
Modifier aggregation: ((Base + Additive) * Multiplicative) / Division
- Multiply/Divide uses
1 + Sum(Mods - 1) -- two +50% multipliers = +100%, not +125%
Ability Lifecycle
GiveAbility() -> TryActivateAbility() -> CanActivateAbility()
-> ActivateAbility() [override this] -> CommitAbility() [apply cost/cooldown]
-> ... do work (AbilityTasks) ... -> EndAbility()
Four activation methods: explicit handle, GameplayEvent, GameplayEffect tags, Input codes.
Instancing policies:
InstancedPerActor -- recommended default; one instance reused per actor
InstancedPerExecution -- new instance each activation; simplest but heaviest
NonInstanced -- uses CDO; best performance, C++ only, no state/delegates/RPCs
Networking & Prediction
See references/networking.md for replication modes, prediction details, and multiplayer patterns.
Net Execution Policies: LocalPredicted, LocalOnly, ServerOnly, ServerInitiated.
Key rules:
- ASC replicates Attributes and Tags to all clients, but NOT abilities/effects (bandwidth optimization)
- Non-instant GEs support prediction rollback; instant GEs (damage) do NOT
- Cues use unreliable replication -- cosmetic only, never gameplay logic
- ASC's owning Actor must be locally controlled for remote activation to work
- For PlayerState-based ASC: use Mixed replication for players, Minimal for AI
Common Patterns & Pitfalls
See references/patterns-and-pitfalls.md for implementation recipes and known issues.
Critical pitfalls:
PreAttributeChange clamping does NOT permanently change modifiers -- clamp BaseValue in PostGameplayEffectExecute instead
Server Respects Remote Ability Cancellation causes more trouble than it's worth -- disable it
Replication Policy on GameplayAbility is misleadingly named -- do not use it
- PlayerState
NetUpdateFrequency defaults too low -- increase it or enable Adaptive Network Update Frequency
- Removing AttributeSets at runtime can crash clients
- Animation montages must use
PlayMontageAndWait AbilityTask, not direct PlayMontage, for replication
1---2name: unreal-gas3description: Expert guide for Unreal Engine 5.x Gameplay Ability System (GAS) C++ development. Covers AbilitySystemComponent, GameplayAbilities, GameplayEffects, Attributes/AttributeSets, GameplayTags, GameplayCues, AbilityTasks, prediction/replication, and common patterns. Use when the user asks about GAS, gameplay abilities, gameplay effects, attribute sets, ability system component, gameplay tags in the context of GAS, gameplay cues, ability tasks, or any UAbilitySystemComponent / UGameplayAbility / UGameplayEffect / UAttributeSet related C++ code. Also triggers for questions about ability prediction, ability replication, combo systems using GAS, cooldowns, costs, stacking, or damage/healing pipelines built on GAS.4---56# Unreal Engine Gameplay Ability System (GAS) -- C++ Guide78## Official Documentation (always consult for latest details)910These are the authoritative sources. Reference them for up-to-date API details, as GAS evolves across engine versions:1112| Source | URL |13|--------|-----|14| **Epic GAS Landing Page** | https://dev.epicgames.com/documentation/en-us/unreal-engine/gameplay-ability-system-for-unreal-engine |15| **Understanding GAS (Overview)** | https://dev.epicgames.com/documentation/en-us/unreal-engine/understanding-the-unreal-engine-gameplay-ability-system |16| **ASC & Attributes** | https://dev.epicgames.com/documentation/en-us/unreal-engine/gameplay-ability-system-component-and-gameplay-attributes-in-unreal-engine |17| **Gameplay Abilities** | https://dev.epicgames.com/documentation/en-us/unreal-engine/using-gameplay-abilities-in-unreal-engine |18| **Attributes & Attribute Sets** | https://dev.epicgames.com/documentation/en-us/unreal-engine/gameplay-attributes-and-attribute-sets-for-the-gameplay-ability-system-in-unreal-engine |19| **Gameplay Effects** | https://dev.epicgames.com/documentation/en-us/unreal-engine/gameplay-effects-for-the-gameplay-ability-system-in-unreal-engine |20| **Ability Tasks** | https://dev.epicgames.com/documentation/en-us/unreal-engine/gameplay-ability-tasks-in-unreal-engine |21| **Community GAS Docs (tranek)** | https://github.com/tranek/GASDocumentation |2223The community docs by tranek are the most comprehensive single resource for GAS. They cover advanced topics (prediction internals, optimization, replication modes, pitfalls) that Epic's official docs do not. Always check them for edge cases and production patterns.2425The **Lyra Sample Project** is Epic's recommended working reference implementation for GAS.2627## Plugin Setup28291. Enable **Gameplay Abilities** plugin in the editor302. Add to `Build.cs`:31 ```cpp32 PublicDependencyModuleNames.AddRange(new string[] {33 "GameplayAbilities", "GameplayTags", "GameplayTasks"34 });35 ```363. UE 5.2 and earlier: call `UAbilitySystemGlobals::Get().InitGlobalData()` in your AssetManager or GameInstance. UE 5.3+ does this automatically.3738## Core Architecture3940See [references/core-classes.md](references/core-classes.md) for the full class reference, setup patterns, and C++ code snippets.4142**System overview:**43```44Actor45 +-- UAbilitySystemComponent (ASC) --- manages everything below46 +-- UGameplayAbility instances (granted abilities)47 | +-- UAbilityTask instances (async execution)48 +-- UAttributeSet instances (numeric data)49 +-- Active UGameplayEffect specs (modifiers)50 +-- FGameplayTag container (status/state)51 +-- GameplayCue triggers (cosmetic FX)52```5354**Key relationships:**55- ASC is the central hub; one per Actor (place on Pawn or PlayerState)56- Abilities create/apply Effects to modify Attributes and Tags on targets57- Effects auto-trigger Cues when their tags match `GameplayCue.*` tags58- Tags control ability activation, blocking, and cancellation systemically59- AbilityTasks handle async work (montages, delays, targeting) within abilities6061## Gameplay Effects Quick Reference6263See [references/effects-and-attributes.md](references/effects-and-attributes.md) for detailed GE patterns, modifier math, stacking, cooldowns, and attribute handling.6465**Duration types:**66- **Instant** -- modifies BaseValue permanently, never tracked as active67- **Duration** -- modifies CurrentValue, auto-reverts on expiry68- **Infinite** -- persists until explicitly removed6970**Modifier aggregation:** `((Base + Additive) * Multiplicative) / Division`71- Multiply/Divide uses `1 + Sum(Mods - 1)` -- two +50% multipliers = +100%, not +125%7273## Ability Lifecycle7475```76GiveAbility() -> TryActivateAbility() -> CanActivateAbility()77 -> ActivateAbility() [override this] -> CommitAbility() [apply cost/cooldown]78 -> ... do work (AbilityTasks) ... -> EndAbility()79```8081**Four activation methods:** explicit handle, GameplayEvent, GameplayEffect tags, Input codes.8283**Instancing policies:**84- `InstancedPerActor` -- recommended default; one instance reused per actor85- `InstancedPerExecution` -- new instance each activation; simplest but heaviest86- `NonInstanced` -- uses CDO; best performance, C++ only, no state/delegates/RPCs8788## Networking & Prediction8990See [references/networking.md](references/networking.md) for replication modes, prediction details, and multiplayer patterns.9192**Net Execution Policies:** LocalPredicted, LocalOnly, ServerOnly, ServerInitiated.9394**Key rules:**95- ASC replicates Attributes and Tags to all clients, but NOT abilities/effects (bandwidth optimization)96- Non-instant GEs support prediction rollback; instant GEs (damage) do NOT97- Cues use unreliable replication -- cosmetic only, never gameplay logic98- ASC's owning Actor must be locally controlled for remote activation to work99- For PlayerState-based ASC: use Mixed replication for players, Minimal for AI100101## Common Patterns & Pitfalls102103See [references/patterns-and-pitfalls.md](references/patterns-and-pitfalls.md) for implementation recipes and known issues.104105**Critical pitfalls:**106- `PreAttributeChange` clamping does NOT permanently change modifiers -- clamp BaseValue in `PostGameplayEffectExecute` instead107- `Server Respects Remote Ability Cancellation` causes more trouble than it's worth -- disable it108- `Replication Policy` on GameplayAbility is misleadingly named -- do not use it109- PlayerState `NetUpdateFrequency` defaults too low -- increase it or enable Adaptive Network Update Frequency110- Removing AttributeSets at runtime can crash clients111- Animation montages must use `PlayMontageAndWait` AbilityTask, not direct `PlayMontage`, for replication