BlueRoseNote/03-UnrealEngine/Gameplay/GAS/(0)Exploring the Gameplay Ability System (GAS) with an Action RPG Unreal Fest 2022学习笔记.md
2023-06-29 11:55:02 +08:00

4.4 KiB
Raw Permalink Blame History

title, date, excerpt, tags, rating
title date excerpt tags rating
Exploring the Gameplay Ability System (GAS) with an Action RPG Unreal Fest 2022学习笔记 2022-11-10 21:04:35 GAS

前言

原视频:Exploring the Gameplay Ability System (GAS) with an Action RPG Unreal Fest 2022

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比如StrengthFortitude坚韧
  • 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 ClassC++ 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的实体。