Wednesday, October 25, 2017

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 has 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. Everytime 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 functionality 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 instances of BP_EnemySpawnPoint along the paths to act as spawning points for the enemy waves. As can be seen in the next screenshot, I've added a couple of spawn points 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 add an instance each of BP_ProjectileManager & BP_ObjectPoolManager into the level. If you plan to use the pooling system, just set 'Pool Bullet Projectiles?' to true through the details section of the actor. Since this system uses a fixed size pooling system, also make sure to specify the pool size through the 'Pool Size Bullet Projectile' variable.

10. 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 it's default parameters, but if you want to know more about the class, check out the concept overview post for the same at:

Next, add an instance of either BP_BatchedWaveSpawnController or BP_WeightedWaveSpawnController to the level. While most of the default parameters will work right out of the box without any need for customizations, you will have to add references to the enemy spawn points within the publicly exposed array 'BatchedWaveSpawnDataArray', if you're going for the former model. Just make sure to specify the 'SpawnPoint' for each wave by linking it to one of the spawn points added to the level in Step 5.

For further reading about the wave spawning systems, see:
11. 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:

Sunday, October 15, 2017

Top Down Stealth Toolkit Basics: Global Alert Level System

The following information is based on the v2.1 edition of Top Down Stealth 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:

The v2.1 update for Top Down Stealth Toolkit introduced a Global Alert Level Controller (GALC) tasked with controlling high-level AI responses to the player's actions. While all AI agents still retain their individual alert level systems, the GALC acts as an autonomous outside listener that keeps track of stimulus perception events, 
with minimal coupling to existing systems within the toolkit. With every new instance of a stimulus being perceived by an AI agent, the Global Alert Meter keeps rising based on the perceived threat rating of the stimulus. As the meter crosses certain threshold values, the Global Alert Level system kicks into action by activating the designated responses associated with the new state. These could include activation of automated security devices like lasers & turrets, as well as the deployment of reinforcement patrol guards to ramp up the difficulty of the mission over time.

The Global Alert Level Controller provides the following options to control the functioning of the new alert level system:

1. ThreatRatingModifier: Controls the rate at which Global Alert Meter goes up. While the perceived threat value of a stimulus is the major deciding factor when it comes to rising global alert levels, this modifier can help control the overall growth curve without having to tune the threat value of individual stimuli.

2. GlobalAlertLevelEscalationData: Determines how the game state changes in response to an increase in the Global Alert Level, based on the following parameters:

  • AlertLevel: The Global Alert Level associated with the state.
  • AlertMeterTarget: Minimum Global Alert Meter value required to reach the associated level.
  • AlertSystemResponse: Determines the actions taken by the AI in response to an increase in the Global Alert Level. Every time the Global Alert Level reaches a new state, the 'ResponseType' associated with the same gets relayed to the AI Surveillance Controller class which processes the request & performs the necessary actions. While the default setup offers up to three types of responses (Idle, ActivateIdleAgents, & Deploy Backup agents), more customized response types can be easily integrated into the system through this parameter.
  • AlertDisplayBackgroundColor: Determines the background color of the UI element that displays the Global Alert Level.

Tuesday, October 3, 2017

Unreal Engine Experiments: Borderlands 2 Damage Display System

I recently started working on some side projects during free time to experiment with & learn about interesting gameplay systems from my favorite games. And Borderlands 2, being high up on the list, I decided to create a working model of its Damage Display system using blueprints. It's finally done & here is a gif demonstration of the system:

The system uses widget components attached to dynamically spawned actors, to draw the text on screen space. Just as in the game, the floating damage texts move along a parabolic path, while the critical hit status text moves along a normal linear path in the upward direction. Both of them keep scaling up till a certain point along the path, & then start scaling down for the remainder of its journey, thus creating a sort of pop-out effect. Another factor that controls the scaling of the text display is the distance from the player character, thus increasing/decreasing its size [the text becomes less clear over long distances in the video, but is much crisper in the actual game instance] based on player movement.

The Damage Display System is being released for free [no attribution required] through Github at:
So feel free to check it out, & use in your projects if you like it.