Looking into Lyra - Activatable Abilties
How Lyra manages which abilities can be activated when
Gameplay abilities are assigned to player character (an other pawns) when they become available due to the game mode, game phase, or equipped items. The gameplay abilities which are assigned to a character are referred to by Lyra as "activatable" abilities.
The LyraAbilitySystemComponent, which is used as a component of both the part of the player character and the player state, maintains a list of activatable gameplay abilities. Each gameplay ability in the list is associated with one gameplay tag. This pairing of a gameplay ability and a gameplay tag is held in a FGameplayAbilitySpec structure.
The LyraAbilitySystemComponent has a list of these FGameplayAbilitySpec objects
(in the member ActivatableAbilities
), and once a user action is translated to a gameplay tag, this list is searched for items which match that gameplay tag.
Associating Gameplay Tags with Gameplay Abilities
In order to trigger a gameplay ability when a specific gameplay tag comes from the input system it is necessary to pair each gameplay ability with a gameplay tag. These data table assets are used to do this:
Looking at one of these (AbilitySet_ShooterHero), we can see it is a list of abilities and associated input tags. This is one of the sources of the activatable activities list:
The HeroData_ShooterGame asset is a data table based on the LyraPawnData structure. It holds data for each type of character, specifically the HeroData_ShooterGame table has a reference to the AbilitySet_ShooterHero set of abilities, so when the ShooterGame mode is running the Lyra pawn will have the abilities listed in the HeroData_ShooterGame table:
Loading activatable activities into the game state
When an experience finishes loading
ULyraExperienceManagerComponent::OnExperienceLoadComplete()
is called, which calls
ALyraPlayerState::OnExperienceLoaded()
and this calls ALyraPlayerState::SetPawnData()
to copy the abilities to the LyraAbilitySystemComponent of the LyraPlayerState.
Each time the Lyra pawn is spawned these abilities will be made available to the pawn by setting the LyraAbilitySystemComponent of the Lyra pawn to the LyraAbilitySystemComponent stored in the player state.