Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Unreal Gas?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tipoli5890-unreal-gas)
---
name: unreal-gas
description: >-
Unreal Gameplay Ability System: AbilitySystemComponent, attribute sets, abilities, effects,
gameplay tags, replication mode, owner and avatar set-up.
---
# unreal-gas — abilities, attributes, effects and tags
The ability system puts actions, numbers and their changes in one component with its own replication; most set-up bugs are an owner and avatar that were never initialised.
Four pieces, one rule each: the **component** (`UAbilitySystemComponent`) lives on one actor and is initialised with an owner and an avatar on every machine; **attributes** live in an attribute set registered with that component; **abilities** are granted on the server and always end; **effects** are the only way numbers and tags change for good.
## Load what the situation needs
| The situation | Read |
|---|---|
| Adding the ability system to a project | *Set-up in order* below, `reference/asc-setup.md` §1 |
| Player state or pawn for the component; owner and avatar; replication mode | `reference/asc-setup.md` §2 to §4 |
| "Abilities fail on the client", "works for the host only", "null avatar after respawn" | *Initialisation failures* below, `reference/asc-setup.md` §5 |
| Declaring, replicating and clamping attributes; initial values | `reference/attributes.md`, `templates/CourierAttributeSet.h` |
| Granting, activating, committing, ending; policies; prediction; effects and specs | `reference/abilities-and-effects.md`, `templates/VaultAbility.h` |
| Tags: config or native, matching, tags on the component | `reference/tags.md`, `templates/CourierGameplayTags.h` |
| Checking a project's set-up without the engine | `scripts/gas_check.py` |
| Property replication rules in general | `unreal-replication` |
| The player state and character classes the component sits on | `unreal-gameplay-framework` |
| Montages played by abilities | `unreal-animation` |
## Set-up in order
1. **Plugin and modules.** Enable `GameplayAbilities` in the `.uproject`; list
`"GameplayAbilities", "GameplayTags", "GameplayTasks"` in the module's Build.cs (public when
public headers include ability-system headers).
2. **Choose the owner.** Player couriers: the component on `ACourierPlayerState` (stamina and
granted abilities survive a respawn), avatar the character. Sentries and anything that resets
with its body: the component on the pawn, owner and avatar the same actor.
3. **Create the component and the attribute set** in the owner's constructor, the set after the
component, so it registers itself; `SetReplicationMode(EGameplayEffectReplicationMode::Mixed)`
for players, `Minimal` for AI.
4. **Expose it** through `IAbilitySystemInterface::GetAbilitySystemComponent()` on the owner, and
on the avatar too when they differ.
5. **Initialise on every machine.** `InitAbilityActorInfo(Owner, Avatar)`: in the character's
`PossessedBy` (server) and `OnRep_PlayerState` (client) for a player-state component; again
after every respawn.
6. **Grant on the server** in `PossessedBy`: `GiveAbility(FGameplayAbilitySpec(UVaultAbility::StaticClass(), 1, -1, this))`.
7. **Activate** from input: `TryActivateAbilitiesByTag` with `Courier.Ability.Vault`, or by class.
8. **Check**: `scripts/gas_check.py`, then a two-player run (`unreal-replication` →
`reference/ownership-and-relevancy.md` §6).
Step 5 for the player-state component (the full additions to both classes:
`reference/asc-setup.md` §3):
```cpp
void ACourierCharacter::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController); // server or standalone only
if (ACourierPlayerState* Courier = GetPlayerState<ACourierPlayerState>())
{
Courier->GetAbilitySystemComponent()->InitAbilityActorInfo(Courier, this);
}
}
void ACourierCharacter::OnRep_PlayerState()
{
Super::OnRep_PlayerState(); // clients
if (ACourierPlayerState* Courier = GetPlayerState<ACourierPlayerState>())
{
Courier->GetAbilitySystemComponent()->InitAbilityActorInfo(Courier, this);
}
}
```
## The ability's shape
```cpp
void UVaultAbility::ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo,
const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData)
{
if (!CommitAbility(Handle, ActorInfo, ActivationInfo, nullptr)) // pays GE_StaminaDrain
{
EndAbility(Handle, ActorInfo, ActivationInfo, true, true);
return;
}
if (ACharacter* Courier = Cast<ACharacter>(GetAvatarActorFromActorInfo()))
{
Courier->Jump();
}
EndAbility(Handle, ActorInfo, ActivationInfo, true, false); // on every path
}
```
In the Blueprint child `GA_Vault`: Instancing Policy Instanced Per Actor, Net Execution Policy
Local Predicted (the client runs it at once; the server can override; instant changes such as
damage do not roll back), cost effect `GE_StaminaDrain`. Long work (the `AM_Vault` montage) runs in
an ability task such as `UAbilityTask_PlayMontageAndWait`, and the ability ends from its delegate.
## Attributes in short
`FGameplayAttributeData` members that are `UPROPERTY`s, with the four
`GAMEPLAYATTRIBUTE_PROPERTY_GETTER` / `_VALUE_GETTER` / `_VALUE_SETTER` / `_VALUE_INITTER`
macros; replicated with `ReplicatedUsing = OnRep_<Attr>`, a `UFUNCTION()` repnotify that calls
`GAMEPLAYATTRIBUTE_REPNOTIFY`, and
`DOREPLIFETIME_CONDITION_NOTIFY(UCourierAttributeSet, Stamina, COND_None, REPNOTIFY_Always)`.
Clamp in `PreAttributeChange` (every change, no side effects) and again in
`PostGameplayEffectExecute` (after an execution changed the base value).
## Initialisation failures
| Symptom | Cause |
|---|---|
| Activation fails on the owning client, works on the server | no client-side `InitAbilityActorInfo` (`OnRep_PlayerState`) |
| Works for the listen-server host only | the same, or abilities given on a client; only the server gives |
| Avatar null or stale after a respawn | `InitAbilityActorInfo` not called again with the new pawn |
| `GetSet<UCourierAttributeSet>()` null, attributes read 0 | the set created on another actor than the component's owner |
| The vault works once | `EndAbility` missing on a path |
| Clients see the start value of Stamina only | the attribute not registered for replication |
| Compile or link errors on ability-system types | a module missing from Build.cs, or the plugin disabled |
Causes and fixes in full: `reference/asc-setup.md` §5, `reference/attributes.md` §7,
`reference/abilities-and-effects.md` §6, `reference/tags.md` §5.
## Check it without the engine
```bash
python3 scripts/gas_check.py /path/to/CourierRun
python3 scripts/gas_check.py /path/to/CourierRun --strict # warnings fail too
```
FAIL lines: an ability-system header without its Build.cs module, the plugin disabled, an
attribute that is not a `UPROPERTY`, a replicated attribute with no registration or a repnotify
that is not a `UFUNCTION` or skips `GAMEPLAYATTRIBUTE_REPNOTIFY`, and a class that lists
`IAbilitySystemInterface` without `GetAbilitySystemComponent`. WARN lines: GameplayAbilities
without GameplayTags or GameplayTasks, no enabled plugin entry, a registration without
`REPNOTIFY_Always`, no `InitAbilityActorInfo` anywhere, a player-state component missing its
`OnRep_PlayerState` or `PossessedBy` initialisation, `GiveAbility` without an authority check,
and `Minimal` on a player's component. It reads no Blueprint, Default Starting Data or data table;
`0 attribute sets, 0 components` means nothing was judged.
## Related skills
- Property replication, RPCs and ownership: `unreal-replication`
- The player state and character classes: `unreal-gameplay-framework`
- The input handler that activates the vault: `unreal-enhanced-input`
- Montages and notifies inside abilities: `unreal-animation`
- Build.cs and plugin entries: `unreal-modules-build`