Tower Defense Starter Kit

Tower Defense Starter Kit Tutorial: How to add new levels to the Level Selection Menu

The Tower Defense Starter Kit comes equipped with a level selection menu that enables players to choose from a list of levels as shown below:

b85618181d9171409a8525c854e563edc17a954d.jpeg

The toolkit contains three playable maps & one main menu map by default, & supports usage of new custom maps as well. The following steps go over the process of adding your own custom levels into the toolkit:

  1. Create a new custom level from the Content Browser.

  2. Open the ‘BP_GameInstance’ blueprint within the Blueprints folder & select the variable ‘LevelDataArray’. It should have four entries by default: one for the main menu & three for the sample maps. To add our new custom map, first add a new element to this array.

Each element of this struct array contains the following attributes: ID, ScreenName, FileName, Image, & Unlocked. The ID is used to set the level number, starting with ‘0’ for the main menu level. It is not used for any calculations & serves only to provide a means for classification of levels. The ScreenName determines the name that would be displayed for the corresponding entry in the level selection menu. The FileName is used to store the address of the level asset. The Image is used to display a preview shot of the map within the level selection menu, & the Unlocked attribute determines if the level would be unlocked by default. If it isn’t, it will be unlocked, as soon as the player completes the level linked to the previous entry within the Level Data Array.

  1. Fill out the attributes mentioned above for the new level data element. Make sure to copy the name of the new custom map asset within the content browser & paste it into the FileName attributes. Here is a sample entry for a new level that I created:

a6101bfd5295f7cef43b205affef8e3e4d638390.jpeg

  1. Now close the project & delete the ‘Saved’ folder within the project folder. This ensures that the changes made to the Level Data Array do not get overridden by information specified in an existing save game file.

  2. Now open the project, open up the main menu level from the ‘Maps’ folder within the Content Browser, & launch an instance of the game. The level selection menu will now display information about the new level, provided that it’s been set to Unlocked. Here is a sample screenshot with the new custom level:

1be3656c5479fb635ae18ab35b0d0af0a0c71168.jpeg

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

Note: I’ve reduced the pixel quality of the sample screenshots to make it easier to load in the forum page. If the images are not clear enough, you can check out higher quality versions from the associated blog post at Unreal Possibilities: https://unrealpossibilities.blogspot.in/2016/12/tower-defense-starter-kit-tutorial-how_28.html]

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:

  1. 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.]

  1. 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.

  1. 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:

  1. 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.

Just wanted to make sure that the price is $29.99 and unlike the previous time, there was no error in displaying the price?

Sorry for the late reply, I did not receive a notification for the comment. The pricing of the product has remained at USD 29.99 for quite a long time. But I think it varies between USD 29.99 & 34.99 depending on the country from which you’re purchasing it [More details here: https://forums.unrealengine.com/showthread.php?81534-Marketplace-prices-EU-VAT]. So the issue pointed out in one of the earlier comments was probably a result of that & the launch price of the product being USD 24.99.

Update 6 (v1.6) has gone live on the Unreal Engine Marketplace. This is a v4.14 exclusive update & listed below are the main changes introduced in this update:

  1. Added a new component to handle the ‘Lock-on System’ for Towers. The core functionality of the towers remain the same, but moving the aforementioned feature out of the tower using a modular component based approach should significantly improve the workflow involved in adding new custom Towers.

As of this update, towers like the Laser Tower, Machine Gun Tower, Sniper Tower, & the Artillery Tower, that focus on a single target actor/region are equipped with the new Turret Lock-on system.

  1. Added a new AI class: the Tower Disabler. The Tower Disabler bots periodically triggers EMP waves that temporarily deactivate nearby towers. Deactivated towers cease to perform their core functions & do not respond to player-driven UI operations like Upgrades, Tower Abilities, etc.

Gameplay demo of the v1.6.1 Tower Defense Starter Kit (Windows): https://www.dropbox.com/s/7wx5blp48kvsxiv/Tower%20Defense%20Starter%20Kit%20Sample%20Game%20Demo.7z?dl=0

All changes within the blueprints are marked with the boolean variable ‘Version1.6’ in order to easily identify the workflow changes introduced with this update. Comments are also written to describe the major changes. The new variables as well as functions added to existing blueprints are also marked in the event graph as shown below:


Changes in the Content Browser:

  1. Added new actor component: BPC_TurretLockOnSystem.

  2. Added new character blueprint: BP_EnemyAI_TowerDisabler.

  3. Added new entry to the enum ‘ECreepType’: Disabler.

  4. Added new interface: BPI_TurretLockOnSystem.

Hi, why cant i add other maps or even change its name or do anything with it in the LEVEL SELECT HUD? i changed stuff in the BP_gameinstance but its not enough i guess.

Hi Hextion, I apologize for the delayed response. I had not been getting any notification from the forum for some reason. As for your query, I suppose that you’re not seeing any changes to the HUD because it might be loading the data from a previous save game file. Since this file could potentially have the Level Data from before the changes, it might be getting loaded/saved back during every instance.

You can resolve this issue by deleting the ‘Saved’ folder within the main project folder. This should ensure that your new edited level data is being loaded the next time since it has no save file to load from. And thanks for pointing this out. I’ve added this information to the tutorial for the same.

Tower Defense Starter Kit Tutorial: How to create custom Towers

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:

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

  2. 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:

  1. 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:

  1. 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.

‘Widget_TargetInformation’:

‘Widget_TowerSelectionButton’:

‘Widget_LoadoutMenu’:

With that, we have covered the basic steps involved in creating a basic Tower class.

Hello I just got this from the marketplace. When i place down grids in a new level i cannot interact with them. I have everything that is in the example maps. Is there something i can to reference it to somewhere? please let me know :stuck_out_tongue:

Hello Firezown, could you confirm if you have already placed the actors marked within the red borders in the screenshot below?

If you’ve already done that, could you check out the ‘Grid Cell Size’ parameter under the User Defined section of the ‘BP_GridManager’ actor. I just noticed that it’s set to a default value of zero while the sample maps use a value of 400 units. So just make sure that it’s set to a positive value.

Yeah i have all of those in the level. I also have the the grid cell size set at 500. Also i cannot use the abilities. It gives me the targeter but they dont do anything.Here is a video.

[video]https://youtu.be/u56-gHPJ8gI[/video]

In order to activate Global Abilities, the actors that support targeting on their surfaces need to satisfy two conditions:

  1. The targetable surface needs to have the actor tag ‘GlobalAbilityTarget’. This conditions determines if the ability can be deployed on a particular surface or not.

  2. It should block the ‘GlobalAbilityTargeting’ trace channel. Apart from the normally targetable surfaces like the AI Path meshes, this condition is also satisfied by the Kill Z volume as it helps the players track the reticule even when they the mouse cursor is focused on empty spaces as shown below:

So basically the reticule remains white on areas like these where the ability cannot be deployed, & turns to red on deployable surfaces based on condition 1) like the AI path meshes.

And as for the lack of grid cell detection, could you try moving the Kill Z Volume actor a few thousand units below it’s current position. It blocks all types of traces & I just want to make sure that it isn’t blocking the traces before they hit the grid cells.

Ok, the kill Z was the problem i can now interact with the grids. Also i changed the tag on the plane to GlobalAbilityTarget but now all i can target with the abilities is the grids if i move off the grid my cursor goes away. And is there an option for more tangets on the spline to make a maze type map like you have above for the enemy to walk.

Alright, glad to hear that it’s fixed. :slight_smile: I saw that you have a floor mesh on which you’ve placed your grid generator. So just set it’s collision settings to block the GlobalAbilityTargeting trace channel, & add the GlobalAbilityTag to it as well. It should start showing the reticule on that surface as well.

In the map shown in the screenshot, I’m just using the Unreal Engine’s nav mesh to calculate the path points. But if you check out the second map focused on the spline based paths, you can see how to create an AI pathing system similar to how it’s done in Kingdom Rush. While you will have to draw out the spline yourself, the toolkit provides you with the support for automatically creating user specified number of multiple spline lanes around the primary lane as well as customization of other parameters like lane gap distance, spline sharpness, etc. You can control all these settings through the Enemy Spawn Point actor:

Also make sure that you set the parameter ‘Navigation Type’ in the Wave Manager actor details to 'FixedSplinePath; as shown below:

This parameter basically informs the AI Bots about the type of pathing system they are supposed to use.

Sorry im having so much trouble with this. The cursor shows up now but nothing spawns when click. Also enemies fall through the floor. I updated to 4.15.1 before i purchased this idk if that is why im having all these issues or im just not understanding this yet.

Don’t worry about that. I don’t think v4.15 is the issue here since these functionalities are working in the sample maps.

The enemies falling through the floor is probably some mismatch in the collision settings. If you’re using a custom mesh for your floor, it would be best if you make sure that the collision settings for it match the AI Path static meshes (you can find it under the collision settings in static mesh editor for SM_FoundationMesh) used in the sample maps.

If the Global Ability is not being deployed, then could you check if a breakpoint added at the node marked in the screenshot is being triggered? (when you try to deploy a global ability on a surface)

Fixed the enemy spawning i had to set my floor object as “Foundation Mesh”.I added a breakpoint to that node you have shown above and it doesnt seem to be firing. I then put down your floor mesh and it still doesnt fire.

Alright then, so it’s probably an issue with not being able to find a deployable surface. Could you try out setting breakpoints on the two branch statements within the same function & see if either of them triggers when you try to active a global ability?

Both of the branches trigger but the “deploy global ability” does not.

So basically the second branch condition is turning out to be false, which means that the actor hit by the trace does not have the ‘GlobalAbilityTarget’ tag.