106 lines
4.4 KiB
Markdown
106 lines
4.4 KiB
Markdown
---
|
||
title: Exploring the Gameplay Ability System (GAS) with an Action RPG Unreal Fest 2022学习笔记
|
||
date: 2022-11-10 21:04:35
|
||
excerpt:
|
||
tags: GAS
|
||
rating: ⭐
|
||
---
|
||
## 前言
|
||
原视频:[Exploring the Gameplay Ability System (GAS) with an Action RPG Unreal Fest 2022](https://www.youtube.com/watch?v=tc542u36JR0&t)
|
||
|
||
## InitialSetup
|
||
首先需要考虑:
|
||
- 哪些`AttributeSets`需要创建
|
||
- 如何让角色获取`GrantAbility`
|
||
- 如何绑定按键与控制器输出事件
|
||
|
||
## CharacterSetup
|
||
- 继承并实现`IAbilitySystemInterface`
|
||
- 挂载ASC,但一般还是挂载到PlayerState上。
|
||
- 在构造函数中创建默认子物体:
|
||
- AbilitySystemComponent
|
||
- AttributeSetObject
|
||
|
||
### PossessedBy
|
||
- AbilitySystemComponent->InitAbilityActorInfo(AActor* InOwnerActor, AActor* InAvatarActor)
|
||
- InitializeAttributes
|
||
- Listen for tags of interest(via UAsyncATaskGameplayTagAddedRemoved)
|
||
- Add start-up effects
|
||
- Bind to Ability activation failed callback
|
||
|
||
### BeginPlay
|
||
Listen to Health Attribute change
|
||
Bind to ASC->OnImmunity
|
||
|
||
## AttributeSets
|
||
- PrimaryAttributes——核心RPG状态,绝大多数实体需要
|
||
- Health,MaxHealth,Shields,MaxShields,Stamina
|
||
- Core RPG Style values(比如Strength,Fortitude(坚韧)等)
|
||
- SecondaryAttributes——一定深度的RPG状态,非所有实体需要
|
||
- Elemental resistances(元素抵抗表),Elemental bonuses(元素奖励),Current Elemental build-Ups(当前元素构建方式)
|
||
- TertiaryAttributes——Bounses(主要用于玩家控制的角色)
|
||
- Interaction speed bonuses,other specific bonuses and stats
|
||
- Weapon archetype specific Attribute(武器相关属性)
|
||
- Charge Percent(充能百分比),Spread(扩散),Charge Count(充能次数)
|
||
|
||
### 后续改进
|
||
- PrimaryAttributes
|
||
- 将Health等基本属性分割成自己的属性集
|
||
- 目前,如果我们给一个UObject等设置了一个属性集来跟踪它们的Health,但它们也会保存其他不必要的值。
|
||
- SecondaryAttributes
|
||
- 对这个设计很满意,因为它都是与元素有关的状态,以及buff/debuff属性。
|
||
- TertiaryAttributes
|
||
- 一些属性可以被分割合并到实体特化的属性集中。
|
||
- Weapon archetype specific attributes
|
||
- 一些int类型的Attribute可以使用Stackable GE来代替(属性集只有float类型),通过查询堆栈数目来获取数据。
|
||
|
||
## 演讲者团队增加的额外功能
|
||
- UGameplayAbility
|
||
- Input
|
||
- UInputAction InputAction(Enhanced Input System)
|
||
- Custom Ability Input ID Enum
|
||
- Booleans/Bitfields 开启一些核心功能 ,我们不想对所有Ability增加通过GameplayTags实现的功能
|
||
- Activate On Granted
|
||
- Activate On Input
|
||
- Can Activate Whilst Interacting
|
||
- Cannot Activate Whilst Stunned
|
||
- Cached Owning Character
|
||
- AsyncAbilityTasks
|
||
- Attribute Changed
|
||
- Cooldown Changed
|
||
- GameplayTag Added Removed
|
||
- Wait GE Class Added Removed
|
||

|
||
|
||
## 使用DataTable与C++来初始化属性集
|
||

|
||
|
||
或者就是实现一个结构体基于FAttributeSetIniDiscreteLevel。
|
||
|
||
## 创建自定义节点来传递GE计算结果与Tags
|
||
多次GE的积累计算结果。主要是通过AbilitySystemGlobals来实现
|
||
- GE_Damage
|
||
- Custom Calculation Class:C++ Damage Execution Calculation
|
||
- Conditional GEs
|
||
- GE_BuildUp_Stun
|
||
- Custom Calculation Class: C++ Build Up Calculation
|
||
- Conditional GE: GE_Stunned
|
||
- GE_BuildUp_Burn
|
||
- Custom Calculation Class: C++ Build Up Calculation
|
||
- Conditional GE: GE_Burned
|
||
|
||

|
||

|
||
## 装备属性变化
|
||

|
||

|
||
|
||
## AbilityTraitsTableExample
|
||

|
||
## 该团队AbilityEntitySystem设计
|
||
用来实现子弹变量、AOE、Cnnstruct、角色等带有ASC的实体。
|
||

|
||
|
||
|
||

|