BlueRoseNote/03-UnrealEngine/Gameplay/Lyra/UE5 Lyra学习笔记(3)—GAS.md
2023-06-29 11:55:02 +08:00

2.3 KiB
Raw Permalink Blame History

title, date, tags, rating
title date tags rating
UE5 Lyra学习笔记(3)—GAS 2022-08-09 13:55:20 Lyra Gameplay

LyraGame

主要逻辑集中在这个模块与插件中本文先解析GAS相关与GameFeature的逻辑。

UWorldSubsystem实现了ULyraAudioMixEffectsSubsystem、

  • LyraGameplayTags实现单例类 FLyraGameplayTags来管理GAS相关标签。感觉不如使用JSON导入DataTable Asset的方式来管理GameplayTag来得方便。
  • LyraLogChannels实现LogLyra、LogLyraExperience、LogLyraAbilitySystem、LogLyraTeams日志标签以及 返回网络Role字符串函数。

AbilitySystem

  • Abilities
  • Interaction
  • Inventory
  • Player
  • Weapons
  • UI

Abilities

LyraGameplayAbility

  • 实现5个ActorInfo获取函数GetLyraAbilitySystemComponentFromActorInfo、GetLyraPlayerControllerFromActorInfo、GetControllerFromActorInfo、GetLyraCharacterFromActorInfo、GetHeroComponentFromActorInfo。

定义ELyraAbilityActivationPolicy与ELyraAbilityActivationGroup枚举并在类内的定义枚举变量与取值函数。用于

c++中实现:

  • ULyraGameplayAbility_Death执行类型为ServerInitiated逻辑为能力激活与结束时调用角色的ULyraHealthComponent的StartDeath()与FinishDeath()。
  • ULyraGameplayAbility_Jump执行类型为LocalPredicted调用角色的Jump()、UnCrouch()、StopJumping()。
  • ULyraGameplayAbility_Reset执行类型为ServerInitiated角色复活时调用的能力将各个属性恢复成初始值,调用角色Reset()之后通过UGameplayMessageSubsystem广播FLyraPlayerResetMessage消息。会在GAS组件接收到GameplayEvent.RequestReset事件时激活。

Animation

ULyraAnimInstance针对GAS进行了定制定义FGameplayTagBlueprintPropertyMap变量。可以在AnimBP中添加FGameplayTagBlueprintPropertyMapping,主要作用是:

  • NativeInitializeAnimation获取Actor的GAS组件用于给FGameplayTagBlueprintPropertyMap变量进行初始化。
  • NativeUpdateAnimation获取Actor的Movement组件通过GetGroundInfo()来获取Actor到地面的距离来给类的GroundDistance变量赋值。
  • IsDataValid用判断AnimBP Asset以及GameplayTagPropertyMap变量是否有效。

GameFeatures

Lyra中实现的

GameFeatureAction

GameModes

Input