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: