Tower Defense Starter Kit Tutorial: How to create custom Enemy Units

[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 comes equipped with four types of Enemy AI units that all derive from the parent blueprint 'BP_EnemyAI_Parent'. As the name suggests, this tutorial goes over the process of adding your own new customized AI units into the mix.

1. First add a new entry to the enum 'ECreepType. I'm going to call it Exploder as I want this new AI unit to explode when destroyed, thus dealing heavy damage to all Tower Guardians/Towers caught in the explosion.

2. Now create a new child blueprint derived from the 'BP_EnemyAI_Parent' class. By inheriting from this class, our new AI unit will have all the basic capabilities that will be required of it including damage & threat response mechanisms, movement logic, etc. At this point, all you have to do is to set the skeletal mesh & animation blueprint from it's components tab based on your requirements.

3. Set values for the default 'User Defined' attributes of this unit & add new variables named 'Explosion Damage' & 'ExplosionDamageRadius' as shown in the screenshot below:


4. Now override & extend the 'End Play' event of the parent class by adding the explosion damage application logic as shown in the previous screenshot.

[Note: Steps 5 & 6 are only required if you intend to use the Group Based Wave Generation System from the Wave Manager.]

5. Head over to the 'BP_EnemySpawnPoint' blueprint & add a custom event similar to the other SpawnCreepBatch events present in it's Event Graph. Check out the next screenshot to see how it's done. Basically this takes care of the creep spawning mechanism, once the wave generator has decided to spawn this particular type of creep.


6. Now the Wave Manager needs to know that it can call this Event to spawn a batch of Exploder bots. So make the changes marked in red in the next screenshot, within your wave manager blueprint:


7. All that's left now is to add our new Exploder bot into the Wave Data Array as shown in the example below:



With that, we have covered the steps involved in creating a very basic Enemy AI template. All classes derived from the EnemyAI_Parent class will be capable of engaging in melee combat with the Tower Guardians. If you want your custom AI bot to engage in ranged combat with the Towers as well, just follow the logic implemented within the BP_EnemyAI_Ranged blueprint.

FPS Tower Defense Toolkit Tutorial: How to use Towers without Tower Bases

[The following information is based on the v1.9 edition of FPS Tower Defense Toolkit & 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?79300-FPS-Tower-Defense-Toolkit]

The FPS Tower Defense Toolkit lets players construct mazes using Tower Bases to control the paths of AI bots. The same Tower Bases also act as platforms for placement of Towers, which help prevent the AI bots from reaching the Power Core. However since most Tower Defense games allow players to directly place towers on the ground instead of a separate platform like Tower Bases, I've received a few queries about how to implement the aforementioned design with this toolkit. This tutorial goes over the modifications required for achieving the same.



BP_TowerManager:


1. Set the variable 'TowerZOffset' to 0.0. This variable determines the offset of the towers along the z axis relative to the ground location. The offset ensured that towers were spawned physically on top of the Tower Bases. Since we're not going to use Tower Bases in this particular scenario, a value of 0.0 ensures that the towers are spawned directly on top of the ground.


2. Now head over to the 'Destroy Tower' function & replace the value of 'Grid Status' input parameter for the 'Update Grid Data Array' function call from 'Tower Base' to 'Empty' [check screenshot below]. Having it set to Tower Base ensured that when a Tower is destroyed, the grid status would revert back to the Tower Base on which it was placed. In our case, we can directly set it to Empty as we're not dealing with Tower Bases.




3. Remove the function call 'Add Tower Base Entry to Selected Tower Data Array' within the 'Create Selected Tower Data Array' function & connect the nodes as shown in the screenshot below:





BP_AttackTowerActual_Parent:


1. Within the Construction Script, add the segment marked with red border in the next screenshot [check below]. This code ensures that the nav paths are rebuilt every time a tower is placed in the level. Since towers used to be placed on tower bases, we only had to do this when tower bases were spawned. And now since towers are going to be placed directly on the ground, we're calling the same functionality here as well.




2. In the Event Graph, add a new 'Event End Play' node & add the segment marked with red border in the screenshot below. This performs the same function as last step, the difference being that we're requesting the nav mesh to rebuild itself everytime a tower is destroyed.




3. Now add a 'Box collision' component to this class. This will act as the nav modifier volume that can block enemy AI paths, thus forcing them along alternate paths. Update the parameters of this component from it's details panel to match the information specified in the following screenshot.





BP_TowerBaseHolo:


1. Now go to the folder 'Holographic Towers'. You should see separate holographic tower classes for Tower Base & Towers. All holographic towers currently inherited from the 'BP_AttackTowerHolo_Parent' blueprint. 


Now the easiest way to modify the Holographic Towers based on our requirements would be to have them inherit from the 'BP_TowerBaseHolo' class. We choose to do this because this class already checks if the tower/towerbase can be placed on the focused grid cell based on the availability of paths from the enemy spawn points to the power core. And with towers being placed at the ground level, this has become a requirement for us. 


However, we still need to make a couple of minor changes within the blueprint. Go to 'Evaluate Tower Resource Requirements' & replace it's logic with the nodes shown in the screenshot below. Basically we're replacing the check for availability of tower bases with a check for availability of tower points.





[Note: You can copy paste these nodes from the same function implementation in  'BP_AttackTowerHolo_Parent' blueprint.]

2. Within the 'Create New Actor Transform' function, replace the 'TowerBaseZOffset' with 'TowerZOffset' as shown in the screenshot below:




3. Now create child blueprints from the 'BP_TowerBaseHolo' class for all the Towers. For example, I'm going to create one child blueprint & name it BP_LaserTowerHolographic. Within the blueprint, we need to set the 'Tower' mesh component to be that of the associated tower. So in this case, I'm just going to set the Laser Tower mesh to this component.


BP_GameInstance:

1. The 'Tower Data Array' variable contains user specified information about all the Towers. If you expand it's elements, you would notice that the first element is a Tower Base entry. Delete this element first.

2. Now expand the array element associated with the Laser Tower & set it's 'TowerHoloClass' parameter as the new holographic laser tower we created a while ago [check next screenshot]. Similarly change the same parameter for every other tower element within the array.



Alright, so now you should be able to use Towers without the need for Tower Bases in your projects. Just make sure to remove references to the Tower Bases & associated enums/blueprints if they're not required. And finally here's a sample screenshot with the final result:


Top Down Stealth Toolkit Tutorial: How to create customized Laser Security Systems

[The following information is based on the v1.4 edition of Top Down Stealth Toolkit & 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?97156-Top-Down-Stealth-Toolkit]


The Laser Security Systems in Top Down Stealth Toolkit function as an auxiliary layer of AI Threat Detection by alerting all nearby patrol bots upon being intercepted by the player. The underlying logic is a simple combination of Timeline based movement & Collision Overlap checks. These actors support drag & drop functionality from the editor & can be easily customized using the variables exposed to the editor from the blueprints. This post goes over the impact of the aforementioned parameters on the working of Laser Security Systems.



1. Length: The Laser Security System uses a box collision component to determine if the player is within it's range. The length parameter determines the total length of this box & also controls the area covered by the laser particle system.

2. Max Height: As described in the tooltip, this variable determines the max height up to which the lasers move relative to the default position at which the actor has been placed in the level.

3. Player Height: The Player Height parameter is used to control the color of the laser based on it's position relative to the ground. Red color indicates that players passing through the laser will trigger an alarm while white color indicates that the laser tracker has moved up beyond the player's height & thus enable safe passage below it. This can be quite useful in top down games, as perception of the location of actors that move along the z plane may not always be intuitive to the player.

4. Alarm Timer: The Alarm Timer value determines how often the alarms are triggered while the laser system has an active target. Since the range of alarm noises are limited, having a timed alarm system can improve the chances of alerting nearby AI patrol bots.

5. Movement Timeline Starting Time: This parameter determines the starting location of the laser along it's movement trajectory. It has a range of 0.0 to 4.0, with 0.0/4.0 representing the starting position [i.e. the location at which the actor was placed] & 2.0 representing the highest position along it's movement trajectory. Anything between 0.0 & 2.0 implies that the laser will have an upward motion going towards the highest point along the trajectory, while a value between 2.0 & 4.0 means that it will have a downward motion going towards the lowest point or the starting position along the trajectory.

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.