ARPG GAS 蓝图使用指南
ARPG GAS 蓝图使用指南
C++ 那一层做了基础设施之后,日常做技能、Buff、Cue 大多在蓝图里完成。这篇整理一个 ARPG 项目里 GAS 蓝图侧的常用结构、节点、模式与配置规范。
1. 标准蓝图能力的 EventGraph
Class Defaults 常用项
| 分类 | 属性 | 说明 |
|---|---|---|
| Tags | Ability Tags | 能力自身标签(标签关系查询用) |
| Tags | Activation Owned Tags | 激活时自动添加到 ASC 的标签 |
| Tags | Activation Required Tags | 激活需要 ASC 拥有的标签 |
| Tags | Activation Blocked Tags | 激活被阻断(ASC 拥有时阻止) |
| Tags | Cancel Abilities With Tag | 激活时取消拥有这些标签的能力 |
| Tags | Block Abilities With Tag | 激活时阻止激活拥有这些标签的能力 |
| Costs | Cost Gameplay Effect Class | 激活的成本 GE 类 |
| Costs | Cost Stamina Percent | 耐力消耗倍率(基于武器耐力属性) |
| Spell | Spell Asset Tag | 法术资产标签 |
| Project Ability | Activation Policy | OnInputTriggered / WhileInputActive / OnSpawn |
| Project Ability | Activation Group | Independent / Exclusive_Replaceable / Exclusive_Blocking |
| Network | Net Execution Policy | LocalPredicted(默认) |
2. 创建新蓝图能力的步骤
2.1 创建蓝图类
- Content Browser → 右键 → Blueprint Class
- 父类:项目能力基类(
UGameplayAbilityProject) - 命名规范:
GA_[角色/系统]_[动作名]- 例:
GA_Player_Atk_Combo1 - 例:
GA_Enemy_Heavy_DashAtk
- 例:
2.2 配置 Class Defaults
Spell:
Spell Asset Tag = SpellAsset.[对应标签]
Activation Policy = OnInputTriggered(普通攻击)或 OnSpawn(被动)
Tags:
Ability Tags = AbilityTagCategory.Action.[对应动作]
Activation Owned Tags = OwnedTagsCategory.Action.[对应动作]
Cancel Abilities With Tag = [需要被取消的能力标签]
Project Ability:
Activation Group = Independent(普通)或 Exclusive_Replaceable(强招)
Costs:
Cost Gameplay Effect Class = GE_Cost_[能力名]
Cost Stamina Percent = 1.0
2.3 实现 ActivateAbility
标准攻击能力的伪代码:
K2_OnAbilityAdded → 初始化变量、预加载资源
K2_OnAbilityRemoved → 清理变量、停止持续特效
2.4 创建 Cost GameplayEffect
参见后文 5.2 节。
2.5 注册到 AbilitySet 或角色蓝图
方式 A(推荐):AbilitySet
- 打开角色对应的
GASets_[角色名].uasset - 在 Gameplay Abilities 数组添加:
- Ability Class =
GA_NewAbility - Ability Level = 1
- Input Tag =
InputTag.[输入按键]
- Ability Class =
方式 B:角色蓝图直接授予
3. 蓝图侧常用节点
3.1 能力执行类
| 节点 | 所在库 | 说明 |
|---|---|---|
Commit Ability | GameplayAbility | 应用成本 + 标签,必须在执行逻辑前调用 |
End Ability | GameplayAbility | 结束能力(bWasCancelled 区分正常/取消) |
Cancel Ability | AbilitySystemBlueprintLibrary | 从外部取消指定能力 |
Try Activate Ability By Class | AbilitySystemBlueprintLibrary | 尝试激活指定类的能力 |
Try Activate Ability By Tag | AbilitySystemBlueprintLibrary | 按标签激活能力 |
Send Gameplay Event to Actor | AbilitySystemBlueprintLibrary | 触发等待中的能力 |
3.2 AbilityTask
| 节点 | 说明 |
|---|---|
Play Montage and Wait For Event | 框架层扩展版,播放蒙太奇并等待 GameplayEvent |
Wait Gameplay Event | 等待特定 GameplayEvent 标签 |
Wait Delay | 等待指定时间 |
Wait Gameplay Tag Added/Removed | 等待标签变化 |
Wait Attribute Change | 等待属性值变化 |
Wait Game State End | 等待 GameState 结束(框架层扩展) |
3.3 ASC 查询
| 节点 | 说明 |
|---|---|
Get Ability System Component | Epic 标准 |
Get Project Ability System Component | 项目扩展版 |
Has Matching Gameplay Tag | 检查 ASC 是否拥有标签 |
Get Owned Gameplay Tags | 获取标签容器 |
Get Attribute Value | 获取属性当前值 |
Is Ability Active | 检查某能力是否在激活中 |
Get Primary Ability Instance From Handle | 获取运行时能力实例 |
3.4 GameplayEffect
| 节点 | 说明 |
|---|---|
Apply Gameplay Effect to Actor | 对目标 Actor 应用 GE |
Apply GE Spec to Target | 用已构建的 Spec 应用 GE |
Make Outgoing Spec | 创建 GE Spec |
Get Project Gameplay Effect Context | 获取自定义上下文 |
Remove Active Gameplay Effect | 按 Handle 移除 GE |
3.5 GameplayCue
| 节点 | 说明 |
|---|---|
Execute Gameplay Cue On Owner | 通过 CueManageComponent 执行一次性 Cue |
Add Gameplay Cue On Owner | 添加持续 Cue(需 Handle 管理移除) |
Remove Gameplay Cue On Owner | 移除持续 Cue |
Execute Gameplay Cue | 直接在 ASC 上执行(标准 GAS 方式) |
4. 常用蓝图模式
模式 A:近战攻击(标准流程)
模式 B:范围伤害(手动 GE 应用)
模式 C:被动能力(OnSpawn 激活)
Class Defaults:Activation Policy = OnSpawn,Ability Tags = AbilityTagCategory.Passive.HealthRegen
被动能力通常不调用 End Ability,保持激活状态。
模式 D:交互能力(按住触发)
Class Defaults:Activation Policy = OnInputTriggered(或 WhileInputActive),Ability Tags = AbilityTagCategory.Action.Interact
模式 E:CAS 上下文动画场景(处决/奥义)
5. GameplayEffect 配置
5.1 伤害 GE(Instant 类型)
Duration Policy: Instant
Modifiers:
[0] Attribute: AS_Health.MetaDelta
Modifier Op: Add
Magnitude Calculation: Set By Caller
Data Tag: Damage.Physical(或具体伤害类型)
[可选] Attribute: AS_Break.MetaDelta
Modifier Op: Add
Magnitude Calculation: Set By Caller
Data Tag: Damage.BreakDamage
[可选] Attribute: AS_Stagger.MetaDelta
Modifier Op: Add
Magnitude Calculation: Set By Caller
Data Tag: Damage.StaggerDamage
Execution Calculations:
[自定义 UExecutionCalcBase 子类]
负责:防御计算、暴击计算、属性捕获
Gameplay Cue Tags:
GameplayCue.Hit.Blood.Blade.Medium
Gameplay Effect Components:
PreApplyBaseGameplayEffectComponent
SetByCallerGameplayEffectComponent
5.2 成本 GE
Duration Policy: Instant
Modifiers:
Attribute: AS_Stamina.MetaDelta
Modifier Op: Add
Magnitude: -20(或使用 Set By Caller)
若使用 CostGameplayEffectParameterInstanced 模式,C++ 会在运行时通过 AddStaminaModifierToCostGE() 动态注入耐力成本。成本 GE 只需提供空模板。
5.3 Buff GE(Duration / Infinite)
Duration Policy: Has Duration (或 Infinite)
Duration Magnitude: Scalable Float(如 5.0 秒)
Modifiers:
Attribute: AttributeSetEnemy.MoveSpeed
Modifier Op: Multiply
Magnitude: 1.3(130% 速度)
Stacking Policy:
Stacking Type: Aggregate By Source
Stack Limit Count: 1
Granted Tags:
OwnedTagsCategory.Buff.Haste
Remove Gameplay Effects with Tags:
OwnedTagsCategory.Buff.Haste(同类 Buff 自动替换)
5.4 BuffGameplayEffect 特殊版
继承 UBuffGameplayEffect 而非 UGameplayEffect,禁用版本继承(每个 Buff 独立版本管理),用于需要严格版本隔离的 Buff(如多段来源叠加计算)。
6. GameplayCue 配置
6.1 GCN Static Burst(最轻量,推荐用于命中特效)
类型:AGameplayCueNotifyStaticBurst
命名:GCN_[效果类型]_[具体描述]
6.2 GCN Actor Looping(持续效果)
类型:AGameplayCueNotifyActorLooping
6.3 Cue 标签命名规范
GameplayCue.[系统].[角色/类型].[动作].[描述]
示例:
GameplayCue.Hit.Blood.Blade.Medium
GameplayCue.Hit.Blood.Blunt.HeavySFX
GameplayCue.Katana.AttackHeavy.PowerAtk4_1SFX
GameplayCue.Hurt.GeneralSoundAction
7. AbilitySet 配置
资产类型:UAbilitySet(DataAsset)
命名:GASets_[角色名][_变体].uasset
GASets_Player.uasset:
Gameplay Abilities:
[0] Ability Class = GA_Player_Dodge_Fwd
Input Tag = InputTag.Dodge
Ability Level = 1
[1] Ability Class = GA_Player_Atk_Combo
Input Tag = InputTag.Attack
Ability Level = 1
[2] Ability Class = GA_Player_Ougi
Input Tag = InputTag.Special
Ability Level = 1
[3] Ability Class = GA_FinishingAction
Input Tag = (无,通过 GameplayEvent 触发)
Ability Level = 1
Gameplay Effects:
[0] Effect Class = GE_InitStats_Player
Effect Level = 1
Attribute Sets:
[0] Attribute Set Class = AS_Health
[1] Attribute Set Class = AS_Stamina
[2] Attribute Set Class = AS_Break
[3] Attribute Set Class = AS_Poise
[4] Attribute Set Class = AS_Stagger
每个角色类型对应一个或多个 AbilitySet,满足不同变体需求(轻装 / 重装 / 不同武器组合等)。
8. TagRelationshipMapping 配置
资产类型:UAbilityTagRelationshipMapping(DataAsset)
Rule [0]:
Ability Tag = AbilityTagCategory.Action.Dodge(闪避)
Ability Tags To Cancel = AbilityTagCategory.Action.Attack.*(取消所有攻击)
Activation Blocked Tags = OwnedTagsCategory.SpecState.KnockOut(被击倒时无法闪避)
Rule [1]:
Ability Tag = AbilityTagCategory.Action.Attack.Heavy(强攻击)
Ability Tags To Block = AbilityTagCategory.Action.Attack.Light(激活期间阻止轻攻击)
Ability Tags To Cancel = AbilityTagCategory.Action.Attack.Light(立即取消轻攻击)
Rule [2]:
Ability Tag = AbilityTagCategory.Action.FinishingAttack(处决)
Ability Tags To Cancel = AbilityTagCategory.Action.*(取消所有动作类能力)
Activation Required Tags = OwnedTagsCategory.SpecState.Break(目标碎甲时才能处决)
一些通用经验
- 能拿 SpellAsset 解决的事不要写在能力蓝图里。 蒙太奇、命中 Cue、近战环参数都丢进 SpellAsset/SpellRingAsset,能力蓝图只负责"挑哪个、用哪段"。
- 永远在
Commit Ability之前做激活条件判定。 一旦 Commit 失败要立即End Ability(Cancelled=true),避免成本被错误扣掉。 Play Montage and Wait for Event是大多数攻击能力的脊椎;它的四条 Exec 分支(Completed / Cancelled / Interrupted / EventReceived)要全部连上,不要漏掉异常路径。- Cue 优先用 Static Burst;只有需要场景 Actor 或循环效果时才上 Actor 类。
- AbilitySet + TagRelationshipMapping 才是真正解耦能力的方式。新增能力先想是不是新增一组规则、一组资源,而不是新写一个 C++ 派生类。