Gameplay Ability System

High-level view of the Gameplay Ability System

Windows
MacOS
Linux

GameplayAbilitySystemTopicImage_01.png

The Gameplay Ability System is a highly-flexible framework for building abilities and attributes of the type you might find in an RPG or MOBA title. You can build actions or passive abilities for the characters in your games to use, status effects that can build up or wear down various attributes as a result of these actions, implement "cooldown" timers or resource costs to regulate the usage of these actions, change the level of the ability and its effects at each level, activate particle or sound effects, and more. Put simply, this system can help you to design, implement, and efficiently network in-game abilities as simple as jumping or as complex as your favorite character's ability set in any modern RPG or MOBA title.

Abilities, Tasks, Attributes, and Effects

Gameplay Abilities (sometimes referred to simply as "Abilities") themselves are C++ or Blueprint children of the UGameplayAbility class. They define what the Ability actually does in C++ code or Blueprint scripting, as well as establishing elements of how the Ability should be treated, such as replication and instancing behaviors.

The logic within a Gameplay Ability will generally call a series of asynchronous building blocks, known as Ability Tasks, in the course of the logic that defines the Ability. Derived from the abstract UAbilityTask class, Ability Tasks are written in C++, and frequently call one of several delegates (in C++) or output execution pins (in Blueprints) when they complete their work, dependent on what the end result was (for example, an Ability that requires a target might have an "aim" task with one delegate or output pin for confirming the target, and another for canceling the Ability).

In addition to Gameplay Abilities, the Gameplay Ability System also supports Gameplay Attributes and Gameplay Effects. Gameplay Attributes are float values stored within the FGameplayAttribute structure that influence the game or the Actor in some way; these are typically values like health, strength, jump height, attack speed, and so on. Gameplay Effects provide a way to alter Gameplay Attributes instantaneously or over time (commonly known as "buffs and debuffs"), such as subtracting magic points when casting a spell, granting a movement speed boost while a "Sprint" Ability is active, or gradually restoring health points over the lifetime of a dose of healing medicine.

Any Actor that interacts with the Gameplay Ability System must have an Ability System Component. This Component will activate Abilities, store Attributes, update Effects, and handle interactions between Actors. Once you have enabled the Gameplay Ability System and created an Actor that includes an Ability System Component, you can begin creating Abilities and determining how Actors should react to them.

System Setup

Because the Gameplay Ability System exists as a Plugin, you will need to opt-in to use it. This is easy to do, and only requires two steps:

  • Enable the Gameplay Ability System Plugin in the Edit -> Plugins window.
    GameplayAbilitySystem_Plugin_00.png

  • To get the full range of capabilities of this system, add "GameplayAbilities", "GameplayTags", and "GameplayTasks" to PublicDependencyModuleNames in your project's "(ProjectName).Build.cs" file. This is easy to do by finding the list of public modules:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });

To use the Gameplay Ability System, add the three module names anywhere in the braced list, as follows:

PublicDependencyModuleNames.AddRange(new string[] { "GameplayAbilities", "GameplayTags", "GameplayTasks", "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay" });

The Ability System Component is the main interface through which your game's characters will access the Gameplay Ability System. This Component manages Gameplay Attributes, runs Gameplay Events, stores Gameplay Abilities, and even handles binding player input to Gameplay Ability activation, confirmation, and cancelation commands. Any Actor that is intended to interact with the Gameplay Ability System should have an Ability System Component.