X157 Dev Notes

One simulant attempts to share insight with others.

How To: Create a New Gameplay Ability

For this tutorial we’re going to make a new ability that executes each time the player presses the keyboard G key.

We will:

The end result will be: Pressing keyboard G will cause our LyraGameplayAbility to execute.

Prefer video? If so jump over to my YouTube tutorial video covering this topic.

Note: The naming convention here is not going to be ideal because this ability is intended only for developer use. For a real ability you’d want to name it something that actually represents what you intend this ability to do. So rather than “Ability G” you’d want to use for example “Ice Trap Ability” or “Shoot Rocket Ability” or whatever, disassociating it with the input required to make the ability happen.

1. Create a New Input Action

Right click in the editor content browser, choose: Input > Input Action

Name it IA_G, configure it as in this screenshot:

IA_G Configuration

2. Create new Gameplay Tag

Open Project Settings, click Project > GameplayTags.

In Gameplay Tags > Gameplay Tag List, add a new tag.

Name the new tag InputTag.Ability.G

3. Add Keyboard Mapping

Open the InputMappingContext where you want the G ability to be active. Mine is called IMC_XG_Default_KBM.

Add IA_G to the list of Mappings > Mappings. Configure it as in this screenshot:

IA_G added to Input Mapping Context

Tip: If you don’t know which InputMappingContext to modify:

4. Map Input Data to Input Tag

Open the LyraInputConfig where you want to be able to use the G ability. Mine is called DA_XG_InputData_Player.

Add a new Ability Input Action (Ability, not Native). Set the Input Action = IA_G and set the Input Tag = InputTag.Ability.G

Add IA_G to LyraInputConfig

Tip: If you don’t know which LyraInputConfig data asset to modify:

5. Create new Lyra Gameplay Ability

Right click on content browser, Blueprint Class, in All Classes search for LyraGameplayAbility. I named mine GA_XG_Player_G.

Here is the Event Graph:

GA_XG_Player_G Event Graph

Here is the DebugPrint function, which is not at all important to this demo other than to show you there is nothing magical happening in here:

GA_XG_Player_G DebugPrint

6. Add New Ability to the Player’s Ability Set

Open the LyraAbilitySet for your player, mine is called DA_XG_AbilitySet_Player.

Add the ability we created, associate it with the Input Tag we created.

Configure it like this:

GA_XG_Player_G ability associated with InputTag.Ability.G

Tip: If you don’t know which LyraAbilitySet data asset to modify:

Congratulations! You’ve Added a new Gameplay Ability

You’ve now added a new Gameplay Ability to Lyra, so when you’re playing the game and you push the G key, this ability will be activated and will run the code you put in its PerformAction function. Put whatever you want there!

In this simple example, my PerformAction just calls DebugPrint, but you can have yours do whatever you want it to do.

DA_XG_Player_G PerformAction

YouTube Video Tutorial

If you have any issues, particularly finding where the appropriate data assets are that you should be editing, check out my YouTube video tutorial on this topic:

YouTube Video Tutorial