Wednesday, March 29, 2017

Tower Defense Starter Kit Tutorial: How to create custom Towers

The following information is based on the v1.6 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:]

The Tower Defense Starter Kit comes equipped with seven types of Tower classes that all derive from the parent blueprint 'BP_Tower_Parent'. As the name suggests, this tutorial goes over the process of adding your own new customized Towers into the mix.

1. First we're going to have to create a new Tower class. To keep things simple, I'm just going to duplicate one of the existing Tower classes named 'BP_ShockwaveTower' & name it 'BP_CustomShockwaveTower'.

If you want to create a tower from scratch, you can do so by creating a child class derived from the 'BP_Tower_Parent' class. The only extra step involved is the setting of static mesh/materials for the 'Tower' static mesh component as shown below:

2. Now we need to make an entry for the same in the 'ETowerType' enumeration. I'm just going to name it Custom Shockwave.

3. The next step in the process is to provide the default stats for our new Tower. Since the toolkit uses a data driven approach to Tower creation, all default user defined attributes for the Towers are specified within the Tower Data Array (in BP_GameInstance class). Again I'm going to duplicate the array element for Shockwave Tower, & change it's 'SpawnClass' & 'TowerType' attributes to 'BP_CustomShockwaveTower' & 'Custom Shockwave' respectively.

The remaining attributes can all be changed based on the specific requirements for the tower & tooltips have been provided to specify the modifications that each attribute brings to the table. Here is a sample screenshot for the custom Shockwave Tower:

4. Now that the default attributes are set up, we need to register the new Tower for Tower Functions which includes Upgrades, Abilities, etc. The 'Tower Functions Array' in the'BP_GameInstance' class determines the functions that are available to the different towers.

To avail all the functions for our new Tower, we just add the associated enum value to the 'Compatible Towers' list for each function as shown below:

5. All that's left now is to make the necessary node connections that rely on the ETowerType enum. I've marked all of them in the screenshots below. Just connect the output nodes from the Custom Shockwave switch case to the designated input nodes as shown in the screenshots & the new tower should be good to go.




With that, we have covered the basic steps involved in creating a basic Tower class. If you have any queries about the procedure, feel free to contact me through the comments section or the aforementioned forum support thread for the Tower Defense Starter Kit.