**FPS Tower Defense Toolkit Tutorial: How to use Towers without Tower Bases [v1.9 edition; For the latest version, check out: **FPS Tower Defense Toolkit Tutorial: How to use Towers without Tower Bases]
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:
-
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.
-
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.
- 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:
- 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.
- 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.
- 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:
- 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.]
- Within the âCreate New Actor Transformâ function, replace the âTowerBaseZOffsetâ with âTowerZOffsetâ as shown in the screenshot below:
BP_GameInstance:
-
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.
-
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: