How to do it...

In the following code, we'll implement a UGameplayAbility derivative called UGameplayAbility_Attack for a Warrior class object. We'll attach this gameplay functionality to the input command string Ability1, which we'll activate on the left-mouse button-click:

  1. Open up your .Build.cs file (in our case, Chapter_11.Build.cs) and add the following dependencies:
using UnrealBuildTool;public class Chapter_11 : ModuleRules{    public Chapter_11(ReadOnlyTargetRules Target) :     base(Target)    {        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;            PublicDependencyModuleNames.AddRange(new string[] {        "Core", "CoreUObject", "Engine", "InputCore" });        PublicDependencyModuleNames.AddRange(new string[] {   "GameplayAbilities", "GameplayTags", "GameplayTasks" ...

Get Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.