Ue Gameplay Ability System 标志

Ue Gameplay Ability System

社区
kevinpbuckley
ue-gameplay-ability-system

Build abilities, attributes, and effects with Unreal's Gameplay Ability System (GAS) — UAbilitySystemComponent (ASC), UGameplayAbility with ActivateAbility/CommitAbility/EndAbility, UAttributeSet with FGameplayAttributeData and ATTRIBUTE_ACCESSORS macro, UGameplayEffect with Instant/HasDuration/Infinite policies and GE Components, FGameplayAbilitySpec for granting, UAbilityTask for async steps (WaitDelay, PlayMontageAndWait, WaitGameplayEvent), GameplayCues for networked VFX/SFX, instancing policies (InstancedPerActor/InstancedPerExecution), net execution policies (LocalPredicted/ServerOnly), and replication modes (Full/Mixed/Minimal). Use when implementing abilities with cooldowns/costs/tags, health/stamina/mana attributes, buffs/debuffs/ damage via Gameplay Effects, ability tasks for async gameplay, Gameplay Cues for cosmetic feedback, or networked server-authoritative ability activation with client prediction. GAS requires the GameplayAbilities plugin and AbilitySystemGlobals initialization.

概览

发布者kevinpbuckley
代码仓库unreal-engine-skills
技能名称ue-gameplay-ability-system
星标数
89
复刻数
9
附带文件
4
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 4 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 kevinpbuckley 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Ue Gameplay Ability System AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/kevinpbuckley/unreal-engine-skills/tree/master/skills/core/ue-gameplay-ability-system
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/kevinpbuckley/unreal-engine-skills.git /tmp/unreal-engine-skills
mkdir -p .claude/skills
cp -r /tmp/unreal-engine-skills/skills/core/ue-gameplay-ability-system .claude/skills/ue-gameplay-ability-system
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Ue Gameplay Ability System,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Ue Gameplay Ability System。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Ue Gameplay Ability System 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Gameplay Ability System (GAS)

GAS is Epic's framework for abilities, attributes, and effects with networking built in. It is powerful but heavyweight — adopt it for games with many interacting abilities/stats; for a couple of simple actions, plain components may be simpler.

When to use this skill

  • Implementing player or enemy abilities with cooldowns, costs, and tag gating.
  • Attributes (health/stamina/mana/armor) modified by buffs, debuffs, and damage.
  • Networked, server-authoritative ability activation with client prediction.
  • Gameplay Cues for cosmetic effects that replicate without bespoke RPCs.
  • Async ability logic: waiting for animation, input, events, or delays inside an ability.

Setup

  1. Enable the Gameplay Abilities plugin (.uplugin → Plugins, or add GameplayAbilitiesPlugin to your .uproject).
  2. Add "GameplayAbilities", "GameplayTags", "GameplayTasks" to your module's Build.cs PublicDependencyModuleNames (see ue-module-and-build-system).
  3. Call UAbilitySystemGlobals::Get().InitGlobalData() exactly once at startup — typically in UAssetManager::StartInitialLoading or your game module's startup function. This is required for target data and montage prediction; omitting it causes silent failures.

Core pieces

TypeRole
UAbilitySystemComponent (ASC)Hub: holds granted abilities, active effects, attribute sets, owned tags
UAttributeSetDeclares attributes (FGameplayAttributeData) and overrides change callbacks
UGameplayAbilityA granted, activatable ability with cost, cooldown, and async logic
UGameplayEffect (GE)Data-driven attribute/tag change: Instant, HasDuration, or Infinite
FGameplayAbilitySpecA granted ability instance (class, level, input ID, source object)
UAbilityTaskAsync step inside an ability (wait for event, montage, delay, target data)
Gameplay CuesCosmetic feedback (VFX/SFX) keyed by GameplayCue.* tags, network-efficient

Where the ASC lives

The ASC can sit on the Pawn or on a separate object (commonly APlayerState):

  • Multiplayer player characters: ASC on the PlayerState so it survives respawn. The Pawn implements IAbilitySystemInterface::GetAbilitySystemComponent() returning the PlayerState's ASC. Call ASC->InitAbilityActorInfo(OwnerActor, AvatarPawn) on the server in PossessedBy and on the client in OnRep_PlayerState (or BeginPlay for listen-server pawns).
  • AI / simple actors: ASC directly on the Pawn; call InitAbilityActorInfo(this, this).
cpp
// Example: Pawn that delegates to PlayerState's ASC
class AMyCharacter : public ACharacter, public IAbilitySystemInterface
{
    GENERATED_BODY()
public:
    virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override
    {
        if (AMyPlayerState* PS = GetPlayerState<AMyPlayerState>())
            return PS->GetAbilitySystemComponent();
        return nullptr;
    }
};

GAS does not support a single Actor having multiple ASCs (ambiguous queries). Multiple Actors can share one ASC (e.g. equipment routing to the character's ASC).

Attributes

Attributes are FGameplayAttributeData properties in a UAttributeSet subclass. Use the ATTRIBUTE_ACCESSORS macro pattern (documented in AttributeSet.h:419) to generate the four helpers: a static FGameplayAttribute getter, a float current-value getter, a setter that routes through the ASC, and a base-value initter.

cpp
// MyAttributeSet.h
#pragma once
#include "AttributeSet.h"
#include "AbilitySystemComponent.h"
#include "MyAttributeSet.generated.h"

// Generates Get<Name>Attribute(), Get<Name>(), Set<Name>(), Init<Name>()
#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
    GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
    GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
    GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
    GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)

UCLASS()
class MYGAME_API UMyAttributeSet : public UAttributeSet
{
    GENERATED_BODY()
public:
    // ReplicatedUsing is required for clients to see attribute changes
    UPROPERTY(BlueprintReadOnly, Category="Attributes", ReplicatedUsing=OnRep_Health)
    FGameplayAttributeData Health;
    ATTRIBUTE_ACCESSORS(UMyAttributeSet, Health)

    UPROPERTY(BlueprintReadOnly, Category="Attributes", ReplicatedUsing=OnRep_MaxHealth)
    FGameplayAttributeData MaxHealth;
    ATTRIBUTE_ACCESSORS(UMyAttributeSet, MaxHealth)

    UFUNCTION() void OnRep_Health(const FGameplayAttributeData& OldHealth);
    UFUNCTION() void OnRep_MaxHealth(const FGameplayAttributeData& OldMaxHealth);

    // Clamp here; do not trigger game logic (use PostGameplayEffectExecute for that)
    virtual void PreAttributeChange(const FGameplayAttribute& Attr, float& NewValue) override;
    // React to confirmed changes (death, UI updates, etc.)
    virtual void PostGameplayEffectExecute(const FGameplayEffectModCallbackData& Data) override;
};

Register the attribute set by creating it as a subobject on the ASC's owning actor:

cpp
// In the owning actor's constructor
AttributeSet = CreateDefaultSubobject<UMyAttributeSet>(TEXT("AttributeSet"));

The ASC auto-discovers UAttributeSet subobjects on the same actor. Never write attribute FGameplayAttributeData fields directly at runtime — always apply a UGameplayEffect so that prediction, replication, and aggregation work correctly.

See references/attributes-and-effects.md for PreAttributeChange vs PostGameplayEffectExecute usage, clamping patterns, and meta-attribute (damage) patterns.

Abilities

cpp
// GA_Dash.h
UCLASS()
class MYGAME_API UGA_Dash : public UGameplayAbility
{
    GENERATED_BODY()
public:
    UGA_Dash();

    // Primary override: do ability work here. Must call CommitAbility then EndAbility.
    virtual void ActivateAbility(const FGameplayAbilitySpecHandle Handle,
        const FGameplayAbilityActorInfo* ActorInfo,
        const FGameplayAbilityActivationInfo ActivationInfo,
        const FGameplayEventData* TriggerEventData) override;

    virtual bool CanActivateAbility(const FGameplayAbilitySpecHandle Handle,
        const FGameplayAbilityActorInfo* ActorInfo,
        const FGameplayTagContainer* SourceTags = nullptr,
        const FGameplayTagContainer* TargetTags = nullptr,
        FGameplayTagContainer* OptionalRelevantTags = nullptr) const override;
};

Key ability lifecycle: CanActivateAbility (read-only check) → CommitAbility (consume cost + cooldown) → ability logic (launch tasks) → EndAbility. Failing to call EndAbility leaves the ability in an active state indefinitely, blocking further uses and any abilities it blocks.

Grant on server:

cpp
// Server only — GiveAbility is authority-only
FGameplayAbilitySpecHandle Handle = ASC->GiveAbility(
    FGameplayAbilitySpec(UGA_Dash::StaticClass(), /*Level=*/1, /*InputID=*/INDEX_NONE));

Activate:

cpp
ASC->TryActivateAbilityByClass(UGA_Dash::StaticClass());
// or by handle:
ASC->TryActivateAbility(Handle);

Cost and cooldown are themselves UGameplayEffect assets referenced by CostGameplayEffectClass and CooldownGameplayEffectClass on the ability. Set these in Blueprint subclasses.

See references/gameplay-abilities.md for instancing policies, net execution policies, tag gating, FGameplayAbilitySpec fields, and event-triggered activation.

Gameplay Effects

GEs are usually data-only Blueprint assets (subclass UGameplayEffect). Choose a duration policy (EGameplayEffectDurationType: Instant, HasDuration, Infinite), add Modifiers (attribute + operation + magnitude), and optionally add GE Components (grants/requires/removes tags, immunity, stacking). Apply from C++:

cpp
// Apply a damage GE from one ASC to another
FGameplayEffectContextHandle Ctx = SourceASC->MakeEffectContext();
Ctx.AddSourceObject(this);
FGameplayEffectSpecHandle Spec = SourceASC->MakeOutgoingSpec(
    DamageEffectClass, /*Level=*/1.f, Ctx);
if (Spec.IsValid())
{
    SourceASC->ApplyGameplayEffectSpecToTarget(*Spec.Data.Get(), TargetASC);
}

UGameplayEffect became component-based in 5.3 (UGameplayEffectComponent subclasses). The legacy monolithic properties still work but new behavior is authored via GE Components. See references/attributes-and-effects.md for GE Components, execution calculations, and stacking.

Ability Tasks

Tasks handle async steps inside an ability. Use NewAbilityTask<T> (not NewObject) and call ReadyForActivation() to start it. Always override OnDestroy to unregister callbacks.

cpp
// Inside ActivateAbility — wait for a montage notify then end
void UGA_Dash::ActivateAbility(...)
{
    if (!CommitAbility(Handle, ActorInfo, ActivationInfo)) { EndAbility(...); return; }

    UAbilityTask_PlayMontageAndWait* Task =
        UAbilityTask_PlayMontageAndWait::CreatePlayMontageAndWaitProxy(
            this, NAME_None, DashMontage);
    Task->OnCompleted.AddDynamic(this, &UGA_Dash::OnMontageCompleted);
    Task->OnCancelled.AddDynamic(this, &UGA_Dash::OnMontageCancelled);
    Task->ReadyForActivation();
}

void UGA_Dash::OnMontageCompleted()
{
    EndAbility(CurrentSpecHandle, CurrentActorInfo, CurrentActivationInfo,
               /*bReplicateEndAbility=*/true, /*bWasCancelled=*/false);
}

Common built-in tasks: UAbilityTask_WaitDelay, UAbilityTask_PlayMontageAndWait, UAbilityTask_WaitGameplayEvent, UAbilityTask_WaitTargetData, UAbilityTask_WaitAttributeChange. All live under Abilities/Tasks/ in the plugin's Public folder.

See references/ability-tasks-and-cues.md for custom task authoring, NewAbilityTask, output delegate patterns, and Gameplay Cues.

Gameplay Cues

Cues are cosmetic effects (particles, sounds, decals) driven by GameplayCue.* tags. They do not need bespoke RPCs — the ASC handles replication automatically.

cpp
// Fire a one-shot cue (e.g. impact spark)
ASC->ExecuteGameplayCue(FGameplayTag::RequestGameplayTag("GameplayCue.Impact.Spark"), Ctx);

// Add a persistent cue (e.g. burning aura) and remove it later
ASC->AddGameplayCue(FGameplayTag::RequestGameplayTag("GameplayCue.Status.Burning"), Ctx);
ASC->RemoveGameplayCue(FGameplayTag::RequestGameplayTag("GameplayCue.Status.Burning"));

Cue handlers are UGameplayCueNotify_Static (one-shot, OnExecute) or UGameplayCueNotify_Actor (spawns an actor, OnActive/WhileActive/OnRemove). Must be tagged GameplayCue.* and registered with the GameplayCue manager (auto-scanned from configured paths).

Networking model

  • The server is authoritative. Grant/remove abilities server-only; effects apply server-side.
  • Set replication mode on the ASC: Full (single-player or small peer-to-peer), Mixed (player-owned ASC in multiplayer), Minimal (AI-owned ASC).
  • Abilities with LocalPredicted net execution policy run immediately on the predicting client and are confirmed or rolled back by the server. Use Gameplay Cues for cosmetic output — they replicate without blocking server authority.
  • Replicated attributes require ReplicatedUsing=OnRep_<Name> and DOREPLIFETIME_CONDITION in GetLifetimeReplicatedProps (handled automatically by the ASC for attribute sets it owns, but you must implement GetLifetimeReplicatedProps on the attribute set).

Gotchas

  • InitGlobalData() not called — montage and target-data prediction break silently.
  • Writing attribute fields directly at runtime — bypasses replication, prediction, and aggregation. Always go through Gameplay Effects.
  • ASC on Pawn for a respawning multiplayer player — state resets on death; put it on APlayerState.
  • Missing module deps (GameplayAbilities/GameplayTags/GameplayTasks) — link errors.
  • EndAbility not called — the ability stays "active" forever, blocking further uses.
  • NonInstanced removed in 5.5 — UE_DEPRECATED_FORGAME(5.5, ...) in 5.8; use InstancedPerActor as the default.
  • Wrong replication mode — Mixed required for player-owned ASCs in multiplayer; Minimal-mode ASCs won't replicate GE data to simulated proxies.
  • Cue tags not prefixed GameplayCue. — the manager won't find or route them.
  • Forgot to call CommitAbility — cost/cooldown not consumed; server may reject prediction.
  • FindOrAddComponent/AddComponent in a GE constructor — NewObject with an empty name fatal-asserts at CDO construction and kills the editor at module load. Use CreateDefaultSubobject + GEComponents.Add instead (see references/attributes-and-effects.md).
  • SetByCaller cost/cooldown with bare CommitAbility — the magnitude is never set, so the spec applies at 0 with a warning. Override ApplyCost/ApplyCooldown (see references/gameplay-abilities.md).
  • No GameplayCueNotifyPaths configured — the cue manager falls back to scanning all of /Game/ (startup warning + scan cost). Set [/Script/GameplayAbilities.AbilitySystemGlobals] +GameplayCueNotifyPaths=/Game/GameplayCues.

Version notes

  • NonInstanced policy deprecated in 5.5; InstancedPerActor is the recommended default.
  • AbilityTags deprecated in 5.5: read GetAssetTags(), set defaults with SetAssetTags(...) (constructor only).
  • UGameplayEffect became component-based in 5.3 (EGameplayEffectVersion::Modular53). Legacy monolithic GE data still works but new functionality is via UGameplayEffectComponent subclasses.
  • GetAbilitySystemComponentFromActorInfo_Checked() deprecated in 5.5; use GetAbilitySystemComponentFromActorInfo_Ensured().

References & source material

Engine source (UE 5.8, Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Public/):

  • AbilitySystemComponent.h — UAbilitySystemComponent: GiveAbility:949, TryActivateAbility:1040, TryActivateAbilityByClass:1032, InitAbilityActorInfo:1523, MakeOutgoingSpec:372, MakeEffectContext:376, ApplyGameplayEffectSpecToTarget:339, SetReplicationMode:268, ExecuteGameplayCue:887, AddGameplayCue:891, RemoveGameplayCue:898, EGameplayEffectReplicationMode enum:81.
  • AttributeSet.h — UAttributeSet:185, FGameplayAttributeData:21, PreAttributeChange:220, PostGameplayEffectExecute:206, ATTRIBUTE_ACCESSORS pattern:419, GAMEPLAYATTRIBUTE_PROPERTY_GETTER:428, GAMEPLAYATTRIBUTE_VALUE_GETTER:435.
  • Abilities/GameplayAbility.h — UGameplayAbility:91, ActivateAbility:574, CommitAbility:336, EndAbility:604, CanActivateAbility:263, CancelAbility:299, EGameplayAbilityInstancingPolicy:37, EGameplayAbilityNetExecutionPolicy:59 (in Abilities/GameplayAbilityTypes.h).
  • GameplayAbilitySpec.h — FGameplayAbilitySpec:168 (class, level, InputID, handle).
  • GameplayEffect.h — UGameplayEffect, EGameplayEffectDurationType:686 (Instant/Infinite/HasDuration), EGameplayEffectVersion:95 (Modular53).
  • AbilitySystemInterface.h — IAbilitySystemInterface::GetAbilitySystemComponent():30.
  • AbilitySystemGlobals.h — UAbilitySystemGlobals::InitGlobalData():69.
  • Abilities/Tasks/AbilityTask.h — UAbilityTask:90, NewAbilityTask<T>:136.
  • GameplayCueNotify_Static.h — UGameplayCueNotify_Static:19.
  • GameplayCueNotify_Actor.h — AGameplayCueNotify_Actor (actor-spawning cue notify):20.

Related skills: ue-gameplay-tags (GAS is tag-driven throughout), ue-networking-and-replication, ue-animation-system (montage tasks).

Official docs (UE 5.8):

Deep-dive references in this skill:

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Ue Gameplay Ability System AI 技能有什么作用?

Build abilities, attributes, and effects with Unreal's Gameplay Ability System (GAS) — UAbilitySystemComponent (ASC), UGameplayAbility with ActivateAbility/CommitAbility/EndAbility, UAttributeSet with FGameplayAttributeData and ATTRIBUTE_ACCESSORS macro, UGameplayEffect with Instant/HasDuration/Infinite policies and GE Components, FGameplayAbilitySpec for granting, UAbilityTask for async steps (WaitDelay, PlayMontageAndWait, WaitGameplayEvent), GameplayCues for networked VFX/SFX, instancing policies (InstancedPerActor/InstancedPerExecution), net execution policies (LocalPredicted/ServerOnly...

为什么在 TypingMind 中使用 Ue Gameplay Ability System?

因为您只需安装一次,就能搭配任何模型使用。Ue Gameplay Ability System 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Ue Gameplay Ability System?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/kevinpbuckley/unreal-engine-skills/tree/master/skills/core/ue-gameplay-ability-system。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Ue Gameplay Ability System?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Ue Gameplay Ability System 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Ue Gameplay Ability System 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Ue Gameplay Ability System AI 技能免费吗?

kevinpbuckley 已在 GitHub 上发布了该技能。请查看代码仓库了解许可条款。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇