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

48 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
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