Tower Defense Starter Kit Tutorial: How to create a new level

1. First, ensure that the default Game Mode & Game Instance class parameters in the Project Settings are set to BP_GameMode & BP_GameInstance classes respectively.

2. Now create a new map, open it, & lay down the navigable area for AI bots by placing instances of BP_AIPath across the level. Add a Navmesh Bounds Volume & extend it to encapsulate all the AIPath actors.


3. Add a Lightmass Importance Volume around the core game space.

4. The BP_AIPath actors that we added earlier have a secondary function apart from providing a traversal space for the AI bots. And that is to allow the deployment of Global Abilities like Airstrike. Every time a player selects a global ability, a targeting reticule is activated to point the precise location for deployment. However, if we have empty spaces in the level, this can be an issue as there will be no surfaces to block the GlobalAbilityTargeting trace channel. In order to rectify this issue, the toolkit provides a solution in the form of the BP_PlayerMovementBounds class. While it is an invisible actor, it can block all types of trace channels, & thus provide a platform for displaying the targeting reticule even when there are no underlying meshes under the cursor location.

So the next step is to add a BP_PlayerMovementBounds actor just below the lowest point along the AI path. Now set it's 'Trace Blocker Extent' parameter to cover an area larger than the maximum visible game space as seen through the player camera. With that, we have essentially added the ability to use Global Abilities.

Now onto the primary functaionality of this actor. As the name suggests, this actor can be used to restrict the movement of the player camera. The movable space for the camera is determined both by the 'Tracer Blocker Extent' value as well as the 'Blocker Bounds To Movement Bounds Ratio' attributes [check screenshot below]. For example, the default ratio of 3.0 to 1.0 ensures that the player camera can move around in an area corresponding to middle one-third of the space covered by the actor's trace blocker volume.


5. Since we've already laid down the paths for the AI bots, the next step is to add spawn points along the paths for the enemy waves.


Now the enemy spawn points are divided into two types based on the navigation model to be used by the AI:

  • BP_SpawnPoint_NavMeshPathing for AI that uses UE4's navmesh to move towards their objectives. [You can use it's Designated Objective' parameter to define the objective actor for all AI bots spawned here]
  • BP_SpawnPoint_SplinePathing for AI that relies on custom spline paths for their movement.
As can be seen in the next screenshot, I've added a couple of spawn points (ignore the old details panel) in my level:


6. Now add a BP_ExitPoint actor somewhere along the path to provide the primary movement target for the enemy AI bots.

7. The toolkit uses modular grid generators to act as platforms for tower placement. But before adding them into the scene, first, add a BP_GridManager actor. Use it's publicly exposed variable 'Grid Cell Size' to specify the size of the individual grid cells across all grid generators in the level.

8. With the grid cell size specified, it's now time to add the grid generators. Drag & drop instances of BP_GridGenerator into the level. The overall size of the generator in the X & Y (local space) directions can be specified through the 'Grid Count X' & 'Grid Count Y' variables as shown below:


9. Now comes two of the most important classes required for the functioning of the toolkit: the Tower Manager & Wave Spawn Controller. Add the BP_TowerManager actor first. There's no need to make any changes to its default parameters as it will work right out of the box with those settings.

Next, add an instance of either BP_BatchedWaveSpawnController or BP_WeightedWaveSpawnController to the level.
 
The Batched Wave Spawn Controller if you want to have complete control over your AI waves. As the name suggests, it works by batching enemies of a similar type into classes so that you can easily set up your own waves. You can check out the following tutorial to learn how to define your own custom waves:


The Weighted Wave Spawn Controller is a more randomized spawning system with less control over the exact nature of enemy waves. For more information on its working, you can check out the following article: Weighted Wave Spawn Controller Basics
 
10. Now onwards to the final step. All that's left to do is to add level bounds so that actors like projectiles that BP_LevelBounds can move across the level gets destroyed once they cross a certain threshold. Add six BP_LevelBounds actors along the outer periphery of the level, making sure that they form a cuboid shape to encapsulate the entire level.



With that, you should have a fully functional level at your disposal. If you have any queries regarding the workflow, feel free to let me know in the comments section.

If you're interested in the toolkit, you can purchase it through the Unreal Engine Marketplace: https://www.unrealengine.com/marketplace/tower-defense-starter-kit

Comments