改造Character
- 在Build.cs里的PublicDependencyModuleNames添加 "GameplayAbilities","GameplayTags","GameplayTasks"
- IAbilitySystemInterface : 继承并实现GetAbilitySystemComponent接口
- AbilitySystemComponent : 技能组件
- GiveAbility : 设定技能
- Try Active Abilities by Tag : 通过标签激活技能
- Try Active Abilities by Class : 通过类激活技能
技能运作的基石
- 很多的Crash
- 保存为DefaultGameplayTags.ini
- Import Tags from Config : 从配置文件导入
- Gameplay Tag Table List Gameplay Tag Table Row : 从DataTable导入
- Add New Gameplay Tag : 添加新的Tag
- Add New Tag Source : 添加新的配置文件
- Gameplay Tag List : 显示所有的Tag
- Restricted Config Files : 限制的配置文件
- Restricted Config Name : 限制的配置文件名
- Owners : 拥有者
- Allow non-restricted children : 是否允许添加子节点
- Restrictred Tag List : 显示限制的Tag,不能删除,只能通过手动修改配置文件
- Gameplay Tag Container : Tag的数组结构,C++:FGameplayTag,FGameplayTagContainer
- Gameplay Tag Operations :
- Matches Tag
- Matches Any Tags
- Has Tag
- Has Any Tags
- Has All Tags
- Exact Match
- Gameplay Tag Query : Tag查询操作,C++:FGameplayTagQuery
- All Expressions Match :所有的表达式都返回True
- Any Expressions Match : 任意一个表达式返回True
- No Expressions Match : 所有表达式返回False
- All Tags Match : 所有都匹配
- Any Tags Match : 任意Tag匹配
- No Tags Match : 任意Tag都不匹配
- IGameplayTagAssetInterface : Actor继承接口
- virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override : 实现接口
- Get All Actors Of Class Matching Tag Query : 使用Blueprint节点
触发技能后主要逻辑
- 启用Gameplay Abilities : Plugins Gameplay
- 创建GameplayAbility
- UGameplayAbility : C++基类
- Event ActiveAbility : 技能激活时
- Event OnEndAbility : 技能结束时
- Tags
- Ability Tags : 技能拥有的标签
- Cancel Abilities with Tag : 激活此技能后,将取消拥有这些标签的技能
- Block Abilities with Tag : 激活此技能后,将阻止拥有这些标签的技能
- Activation Owned Tags : 激活此技能后,将拥有这些附带的标签
- Activation Required Tags : 激活技能时需要的标签
- Activation Blocked Tags : 阻碍激活技能的标签
- Source Required Tags : 源头拥有这些标签才能激活此技能
- Source Blocked Tags : 源头拥有这些标签将阻碍激活此技能
- Target Required Tags : 目标拥有这些标签才能激活此技能
- Target Blocked Tags : 目标拥有这些标签将阻碍激活此技能
- Advanced
- Replication Policy : 是否使用网络同步
- Instancing Policy : 实例化策略
- Non Instanced : 不实例化技能,特点:高效,通过Class Default Object创建。带来的限制: 限制某些功能,没有变量,没有状态,没有Task,不能绑定代理,不能进行网络复制,没有RPC。用于多人频发的技能。测试会Crash。
- Instanced Per Actor : 每个Actor实例化一个技能,只创建一次
- Instanced Per Executation : 每次释放实都实例化技能,每次都创建,最消耗。
- Server Respects Remote Ability Cancellation : 如果为True,服务端会接受客户端的取消操作,客户端总是接受服务端的取消操作。
- Retrigger Instanced Ability : 当Instancing Policy为Instanced Per Actor时才有效,如果为True,激活已经激活的技能,将会结束此技能然后重新激活,如果为False,激活已经激活的技能,将会失败。
- Net Execution Policy : 网络执行策略
- Local Predicted : 客户端执行,拥有较好的响应速度和准确性,释放技能时本地立即执行,但是服务端有最终的决定权,可以覆盖客户端的结果。只要客户端不出错就会非常的流畅。
- Local Only : 客户端执行,适用于单机游戏。
- Server Initiated : 服务器执行,然后通过网络复制同步到客户端,结果最准确,但是会有延迟。
- Server Only : 服务器执行,不进行网络复制,但是受此技能影响的其他变量将会同步到客户端。
- Costs : 消耗,例如:消耗蓝,魔法,体力,血量,怒气等。 通过CommitAbility使用。
- Cost Gameplay Effect Class : Gameplay Effect对象
- Triggers : 通过某些途径触发标签,
- Trigger Tag : 触发的标签
- Trigger Source : 触发来源的种类
- Gameplay Event : 使用Send Gameplay Event to Actor节点,可以携带参数
- Owned Tag Added : 添加标签时触发,先于源标签激活
- Owned Tag Present : 添加标签时触发,当标签被移除时,此触发技能也会结束。先于源标签激活。
- Cooldowns : CD
- Cooldown Gameplay Effect Class : Gameplay Effect对象
- Blueprint逻辑
- GiveAbility :在C++层调用GiveAbility
- Try Activate Ability by Class : 通过类型激活技能
- Try Activate Ability by Tag : 通过标签激活技能
- CommitAbility : 提交技能,检查并应用消耗与CD
- CommitAbilityCooldown : 提交技能,只检查并应用CD
- CommitAbilityCost : 提交技能,只检查并应用消耗
- EndAbility : 在Event ActiveAbility 后面调用,调用后会出发Event OnEndAbility
没有逻辑,通常是配置
- Gameplay Effect
- Duration Policy : 持续策略
- Instant : 瞬时
- Infinite : 永久
- Has Duration : 持续时间,单位:秒
- Magnitude Calculation Type : 时长计算种类
- Scalable Float : 可扩展的浮点数。Raw Value : 基础数值;Curve Table : 读取配置表,最终的结果是根据等级读取并相乘
- Attribute Based : 基于属性,公式: a*(x+b)+c
- Coefficient : a
- Pre Multiply Additive Value : b
- Post Multiply Additive Value : c
- Backing Attribute : 支持属性
- Attribute to Capture : 指定的属性,FGameplayAttributeData类型,公式里的x,未指定将变成无限
- Attribute Source : 属性源。Source和Target
- Snapshot : 是否进行快照。例如火球的伤害是10,当火球发出时就应进行快照,因为释放者的属性可能会在火球飞行的过程中被修改,不能让其影响已经释放了的火球。
- Attribute Curve : 属性配置。如果制定了配置,就会读取配置里的数值,公式变成 a*(x*y+b)+c,公式里的y
- Curve Table : 配置表
- Row Name : 行的名字
- Attribute Calculation Type : 属性计算的类型
- Attribute Magnitude : 使用计算后的结果
- Attribute Base Value : 和上面一样 ?
- Attribute Bonus Magnitude : x不会用Attribute的值
- Source Tag Filter : 不知
- Target Tag Filter : 不知
- Custom Calculation Class : 自定计算,能够使用Blueprint或C++里的多个属性
- Calculation Class : 指定用于计算的类,需要实现CalculateBaseMagnitude方法
- Final Lookup Curve : 最终校正。如果制定有效,将会进一步通过CurveTable计算
- Set by Caller : 不知。 通过调用者设置,如果指定了标签,先通过标签查找,再通过名字查找
- Data Name : 不知。 通过名字查找
- Data Tag : 不知。 通过标签查找
- Magnitude Calculation Type : 时长计算种类
- Modifiers : 修改器列表
- Attribute : 修改的属性
- Modifier Op : 操作
- Add : +
- Multiply : *
- Divide : /
- Override : 覆写
- Modifier Magnitude : 数据的计算, 同Duration Magnitude
- Source Tags : 不知。 需要源遵循的标签规则
- Target Tags : 不知。 需要目标遵循的标签规则
- Executions : 自定义的执行代码
- Calculation Class : Gameplay Effect Execution Calculation类,需要实现Execute方法
- Conditional Gameplay Effects : 如果执行计算成功,将应用额外的效果到目标,如果未指定计算类,将总是应用额外的效果到目标。
- Effect Class : 需要应用的效果
- Required Source Tags : 需要源拥有的标签
- Duration Policy : 持续策略
- Period : 周期
- Period : 周期时长,表示在持续内以固定周期执行效果
- Execute Periodic Effect on Application : 如果为True在应用的时候执行一次,然后固定周期执行一次,如果为False在应用时不会执行,后面固定周期执行一次。
- Application : 应用
- Chance to Apply to Target : 应用此效果的概率,取值范围:[0,1]
- Application Requirement : 应用依赖数组,自定义Gameplay Effect Custom Application Requirement类,需要实现Can Apply Gameplay Effect方法
- Stacking : 堆栈
- Stacking Type : 堆栈类型
- None : 不叠加,每次应用都是独立的
- Aggregate by Source : 以释放者为堆栈
- Aggregate by Target : 以接受者为堆栈
- Stack Limit Count : 堆栈大小
- Stack Duration Refresh Policy : 刷新持续时间的策略
- Refresh on Successful Application : 当成功应用时刷新持续时间
- Nerver Refresh : 从不刷新持续时间
- Stack Period Reset Policy : 重置周期的策略
- Reset on Successful Application : 当成功应用是重置周期
- Never Reset : 从不重置周期
- Stack Expiration Policy : 效果到期的策略,只对有持续时间的效果有效
- Clear Entire Stack : 当效果到期后清空整个堆栈
- Remove Single Stack and Refresh Duration : 移除单个到期的效果,并刷新时间,即堆栈减1,重新开始
- Refresh Duration : 直接刷新时间,相当于无限的效果,需要通过回调(Callback)来手动减少堆栈
- Stacking Type : 堆栈类型
- Overflow : 溢出
- Overflow Effects : 当堆栈溢出时添加的效果,例如:当受到10个冰雪技能后,受到一个冰冻效果
- Deny Overflow Application : 拒绝溢出时应用,为True时表示当堆栈满了时将拒绝继续添加效果,从而导致无法刷新持续时间
- Clear Stack on Overflow : 当Deny Overflow Application为True时才有效。溢出会进行清空
- Expiration : 持续时间到期
- Premature Expiration Effect Classes : 当持续效果被过早终结时使用的效果
- Routine Expiration Effect Classes : 当持续效果自然终结时使用的效果
- Display : 视觉显示,特效,音效,UI。主要使用Gameplay Cue
- Require Modifier Success to Trigger Cues : 为True表示当Modifiers全部执行成功时才会显示视觉效果
- Suppress Stacking Cues : 为True表示只在第一个进栈的效果触发
- Gameplay Cues :
- Magnitude Attribute : 指定的属性,如果未指定则使用等级
- Min Level - Max Level : 用于归一化等级,控制效果有多强
- Gameplay Cue Tags : 拥有专门的Tag,GameplayCue.XXX.YYY
- UIData : 通过UI表示数据等,server-only不可用,GameplayEffectUIData类。
- Tags : 标签
- GameplayEffectAssetTag : 效果拥有的标签,并不会应用到Actor上,FInheritedTagContainer类型,
- Combined Tags : 和Parent组合后的标签
- Added : 需要添加的标签
- Removed : 需要从Parent里移除的标签
- GrantedTags : 携带的标签,效果应用时将会应用到Actor
- Ongoing Tag Requirements : 一但效果应用,这些标签将会决定效果开启还是关闭,效果任然可以被应用但是可以被关闭然后什么都不做。FGameplayTagRequirements类型
- Require Tags : 需要的标签
- Ignore Tags : 不能有的标签
- Application Tag Requirements : 应用效果需要的标签,如果没通过将会应用失败,FGameplayTagRequirements类型。
- Remove Gameplay Effects with Tags : 应用效果时需要移除的标签
- GameplayEffectAssetTag : 效果拥有的标签,并不会应用到Actor上,FInheritedTagContainer类型,
- Immunity : 免疫。不知
- Granted Abilities : 附带的技能
1. Ability : 技能类
2. Level : 技能的等级
3. Input ID : 绑定的InputID
4. Remove Policy : 移除策略,当效果被移除是,附带的技能如何移除
- Cancel Ability Immediately : 立即取消移除
- Remove Ability on End : 等待技能完成,然后移除
- Do Nothing : 不移除,让其自生自灭
- ApplyGameplayEffectToTarget : 通过此Blueprint节点使用效果
用于表现特效,音效
- Gameplay Cue
- Gameplay Cue Tag : 标签
- Auto Attach to Owner : 为True时将在BeginPlay时附加到Actor,有消耗,在需要用时才设为True
- Is Override : 不知
- Unique Instance Per Instigator : 当多个释放者应用Cue到同一个目标时是否创建单独的实例。例如:在目标处播放一个特效或声音不用创建多个实例;创建一个连接释放者和目标的光束就需要创建单独的实例。
- Unique Instance Per Source Object : 当同一个释放者应用Cue到多个目标时是否创建单独的实例
- Allow Multiple on Active Events : 是否能够重复触发OnActive事件,出现在只有一个实例的情况下
- Allow Multiple While Active Events : 是否能够重复触发WhileActive
- Num Preallocated Instances : 预分配实例的数量
- Cleanup :
- Auto Destroy on Remove : 执行OnRemove后这个Actor对象将被删除或者回收
- Auto Destroy Delay : 当Auto Destroy on Remove为True的情况下延迟删除的时间
- Warn if Timeline is Still Running : 当回收时如果还有Timeline运行,将会发出警告。依然会停止Timeline
- Warn if Latent Action Is Still Running : 当回收时如果还有Latent任务运行,将会发出警告。依然会停止Latent
- Function : 可以在这些方法里编写逻辑,比如播特效和音效
- OnActive : 激活时
- WhileActive : 激活时,还未被应用
- OnExecute : 效果执行时,可能是瞬时的或者周期性的
- OnRemove : 移除时
属性集,必须使用C++
- FGameplayAttributeData : 属性类型,推荐使用此类型而不是float
- PreAttributeChange : 修改属性之前执行,例如:修改血量时进行限制,HP=Clamp(0,MaxHP);
- PreAttributeBaseChange : 修改属性基础值之前执行,属性为FGameplayAttributeData才有效
- PreGameplayEffectExecute : 修改属性时执行检查,如果返回True则允许修改,返回False终止修改操作。注意:在效果应用时不会执行,在效果执行时才会执行。
- PostGameplayEffectExecute : 修改属性后执行,注意:在效果应用时不会执行,在效果执行时才会执行。
- GetLifetimeReplicatedProps : DOREPLIFETIME_CONDITION_NOTIFY将属性设置为网络同步
- ReplicatedUsing : OnRep_XXXAttribute
- InitStats : 初始化属性,可以关联DataTable
- FGameplayAttribute :可以通过宏来进行声明和定义
自定义计算
- UGameplayEffectExecutionCalculation : 继承此类
- Execute_Implementation :实现此接口,Blueprint实现Execute方法
- DECLARE_ATTRIBUTE_CAPTUREDEF : 声明宏
- DEFINE_ATTRIBUTE_CAPTUREDEF :定义宏
- RelevantAttributesToCapture : 将需要属性添加到此列表
- InvalidScopedModifierAttributes : 将需要属性添加到此列表
- Attributes :
- Requires Passed in Tags : 是否需要以参数的方式传入标签
- Invalid Scoped Modifier Attributes : 不需要的属性列表,加入此列表里的属性将不会显示在效果界面
- Relevant Attributes to Capture : 需要显示的属性
用于事件的出发,可以携带参数
- FGameplayTag EventTag :事件标签
- const AActor* Instigator : 释放者
- const AActor* Target : 目标
- const UObject* OptionalObject : 可携带其他数据
- const UObject* OptionalObject2 : 同上
- FGameplayEffectContextHandle ContextHandle : 效果上下文,包含其他参数
- FGameplayTagContainer InstigatorTags : 触发事件时释放者的标签,因为后面释放者的标签可能会变
- FGameplayTagContainer TargetTags : 同上,目标标签
- float EventMagnitude : 浮点值
- FGameplayAbilityTargetDataHandle TargetData : 目标的数据
- SendGameplayEventToActor : 出发事件的方法,位于UAbilitySystemBlueprintLibrary
- SendGameplayEvent : 位于UGameplayAbility
-
[Unreal Engine 4(虚幻UE4) GameplayAbilities插件入门教程] https://www.cnblogs.com/JackSamuel/tag/GameplayAbility%E6%8F%92%E4%BB%B6/
-
[WTF Is? Gameplay Tags in Unreal Engine 4 ( UE4 )] https://www.youtube.com/watch?v=e2rdXo408Q0
[Intro to Gameplay Abilities in Unreal Engine 4] https://www.youtube.com/watch?v=Ev2P6BTUxN0
[Intro to the Unreal Engine Gameplay Abilities Module - Unreal Sydney Meetup] https://www.youtube.com/watch?v=OyiweL2nPac
[Tutorial: Custom Abilities in UE4's Action RPG Game (C++ / Blueprint)] https://www.youtube.com/watch?v=Tu5AJKNe1Ok
-
[Gameplay Tags] https://docs.unrealengine.com/en-us/Gameplay/Tags
[Gameplay Ability System] https://docs.unrealengine.com/Gameplay/GameplayAbilitySystem/GameplayAbilities
-
[GameplayAbilities and You] https://forums.unrealengine.com/community/community-content-tools-and-tutorials/110113-gameplayabilities-and-you
[Comprehensive GameplayAbilities Analysis Series] https://forums.unrealengine.com/community/community-content-tools-and-tutorials/116578-comprehensive-gameplayabilities-analysis-series?143688-Comprehensive-GameplayAbilities-Analysis-Series=
-
[Action RPG Game] https://docs.unrealengine.com/en-us/Resources/SampleGames/ARPG
[MCGameplayAbilities] https://github.com/michaeltchapman/MCGameplayAbilities
[Unreal_GameplayAbilities_FirstPerson] https://github.com/DavidENishball/Unreal_GameplayAbilities_FirstPerson
[GASContent] https://github.com/Pantong51/GASContent#gas-intro