Skip to main content

Tower Defense Starter Kit Tutorial: How to create new Global Abilities


[The following information is based on the v1.5 edition of Tower Defense Starter Kit & hence may not remain entirely relevant in later versions. For more information about the toolkit, check out the official support thread in the Unreal Engine forums: https://forums.unrealengine.com/showthread.php?102675-Tower-Defense-Starter-Kit-Support-Thread]


The Tower Defense Starter Kit is equipped two default inbuilt Global Abilities: Airstrike & Tower Guardians. This tutorial goes over the steps involved in creating & adding a new custom Global Ability.

1. First we need to add a new entry to the enum 'EGlobalAbilities' to depict our new custom Ability. I'm going to add an entry named Shockwave, & this particular sample ability will reduce the health of all enemy units in the level.

2. Now we will create an actor component that contains the core functionality of this ability. Basically these ability components will be added to an actor named 'Global Ability Deployer' [which as the name suggests acts as a container for the component], when the ability is activated by the player at runtime. 

As shown in the screenshot below, I've added the logic for retrieving references to all enemy bots in the level, & then reduce their health by a certain amount. Once the job is done, the component requests the owning actor [Global Ability Deployer as mentioned above] to destroy itself. We're doing this because the deployer comes into action only when the ability has been activated.



3. With the custom enum & actor component set in place, it is now possible to add a new entry into the Global Abilities Array within the BP_GameInstance class. For this new member of the array, set the 'AbilityType' parameter to the new enum entry we created earlier; the 'AbilityComponentClass' to the new custom actor component; 'AbilityNameAbbreviation' to the text displayed on the Global Ability Button; 'RechargeDuration' value to the amount of time it takes for the ability to recharge; & finally the 'Unlocked' parameter [it does not do anything at the moment & is reserved for potential future uses] to true. Here's a screenshot depicting the array entry for my new Shockwave ability:



The In-Game HUD takes the data from this array & dynamically displays the Global Ability buttons based on the specified information, thus reducing the need to make any changes to the associated HUD blueprints when abilities are added or removed.

4. Now all that's left is to tell the Global Ability Deployer to handle this new ability. As depicted in the screenshot below, the Deployer will have information regarding the type of ability activated by the player. Using this information, it adds the associated ability component to itself. So when the switch case encounters the Shockwave ability, we just have to add our new Shockwave ability component.