--- title: UE5 Lyra学习笔记(3)—GAS date: 2022-08-09 13:55:20 tags: Lyra Gameplay rating: ⭐️⭐️ --- # 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