Tower Defense Starter Kit

Happy to help :slight_smile: And don’t worry about that. It’s easy to lose track of the minor details when the mind is busy trying to figure out how an entire project works.

Thanks for understanding. My team decided to go with a drag-and-drop UI for the towers, so I’ve been trying to make the menu for the tower list appear on the screen just like the global abilities buttons. I tried copying the GlobalAbilitiesList widget in GameHUD and changing the variables to match the tower data array for a few hours, but I haven’t gotten it to work right yet. Do you know of an easier way to try it, or a quick guide to do it this way?

Alright, so you’re on the right track as both the Global Abilities & Tower Selection List (in Loadout menu) are built using the base widget ‘Horizontal Selection List’. In order to display the tower list in the In Game HUD, you just need to duplicate the ‘Widget_GlobalAbilitiesList’ & pass the Tower Data Array to it as the input as shown below:

That should display the Tower List & it will automatically update it’s size to match the number of towers in the list. Just set it’s position in the In Game HUD widget & you should be good to go ahead & add the drag & drop functionality.

This was simple! Thanks! The info isn’t displaying on the window. If I can’t figure out how to get that working I’ll come back.

So I’ve been able to narrow it down to OnHovered for the TowerBuild button event graph and compared it to the OnHovered event in the Global Abilities button event graph. They both call Update HUD Display, though only the Global Abilities actually update the window with information in-game. The only difference I saw was an update node for “Set User Focus on Widget” in the Global Abilities button that isn’t in TowerBuildButton, but I don’t think it would be the issue. I added the update node for Set User Focus on Widget in TowerBuildButton anyway and see if it changed anything, which it did not.

You’re not able to see any information because we’re actually leveraging an existing functionality that is responsible for creating the tower selection list in the Loadout menu. It uses the Tower Selection Button widgets as it’s children & not the Tower Build Buttons. Hence it has no idea about displaying information on to the Game HUD. Since the intention here is to build towers, the list would have to be populated using the Tower Build Buttons. The easiest way to do this would be to duplicate the ‘CreateTowerSelectionList’ function in the ‘Widget_HorizontalSelectionList’ blueprint, & then modify some of it’s existing logic to create the Tower Build Buttons as shown in the link below:

Dropbox - towerbuildlist.png - Simplify your life [The new forum interface is not responding to screenshot attachments or links]

Now instead of calling this list constructor through the Event Construct in Game HUD event graph, we’ll need to call it manually once all the core actors are initialized at the start of a level. And instead of using the Tower Data Array which holds static information about all Towers, we will have to pass it the Selected Tower Data Array as it holds information about the towers that were selected by the player from the Loadout menu. [Check next screenshot]

All that’s left is to call this function when the player controller gets initialized through it’s ‘InitializePlayerController’ function.

It shows up nicely now! I’ve been studying up on drag-and-drop, so now I just need to apply the feature to the buttons. Thanks again for your help.

Got another question for you. I’m trying to get a widget to show up at each cell to receive an OnDrop command, but so far injecting it into the construction graph of the Grid Generator builds the widget once per generator. How would I be able to add an object to be built at every cell?

I’m not sure if I understood your question. Do you want all cells to be highlighted for displaying potential tower placement spots? Or is it something like having a widget to confirm the placement once a cell has been selected?

As far as I’ve learned about DragDrop operations, only widgets can receive a drop command. I’m trying to get a widget at each cell to receive the drop command so the tower can be built at the cell.

I’ve never worked on a drag & drop system on any of my projects & so I’m not exactly sure if this method would work, but you could try using the drop functionality through the main Game HUD, which is always present during actual gameplay. If you can get that working, then the 2D screen coordinates can be converted to 3D world position & direction [Get Screen Location to World Space - Blueprint - Epic Developer Community Forums], use this to fire a trace in the said direction & check if it hits a grid cell.

I already can get a widget to build at each grid, but it only builds once per grid. I have everything else ready. I just need to know how to get an object to spawn at each cell and it should work as-is.

Another question I have is how to over-ride the code to allow a player to add a tower to a cell that has a tower in it. We want to be able to stack towers.

In order to display widgets at each cell, you will need to access the ‘GridDataArray’ from the BP_GridManager actor. This struct array stores information about all the grid generators in the level. So basically each element holds information about the grid cells within each grid generator. You can do a for loop through the main array, and then again loop through each grid cell entry within the inner array to get a hold of the locations of all grid cells. Using these locations, you can display the widgets at every single cell.

As for overriding the tower placement logic, check out the ‘Manage Selected Actor Information’ function within the Player Controller blueprint. This function basically identifies the entity selected by the player, & responds accordingly. Right now, if it detects a tower, it displays the Tower Functions menu to enable use of Tower Upgrades, Abilities, etc. You can modify this to display the Tower Build menu, as done though the same function when the interacted entity is a grid generator.

The v1.8.1 update for Tower Defense Starter Kit has been submitted for Marketplace review. Since the v4.17 edition of the toolkit is put on hold until v4.17.2 to account for the upcoming engine bug (does not affect PIE, but present in standalone & packaged versions) fix ‘UE-48228’, I’ve decided to push updates through the v4.16 edition.

Change Log:

  1. Modified the Tower Level-Up system to gain experience for every output cycle, irrespective of the output generated.
  2. Fixed a bug that prevented towers from leveling-up multiple times from a single XP boost.
  3. Added world context object references as input parameters for functions within the Blueprint Function Library.

Hello everyone can some one please tell me if and where could i change the ability of only having to select the four towers to maybe five or just all? please and thank you

Hi, you can set the number of available towers through the ‘Tower Manager’ actor present in the level. It has two publicly exposed variables ‘SelectTowersAtLevelStart’ & ‘MaxNumberOfTowerTypes’.

If ‘SelectTowersAtLevelStart’ is set to True, then the player will be able to select the towers through the loadout menu. Else, all towers will be selected by default.

The ‘MaxNumberOfTowerTypes’ allows you to set the number of towers that can be selected by the player during the loadout phase.

Instead of replacing the functions menu with another build menu, I need to add a button on the functions menu that changes the menu to the build menu.
I also need to disallow the functions menu for the first tower in the cell after another tower is stacked on it, and have “repair” apply to both towers in a stack.
In addition, I need to stop allowing towers after the second tower in a cell. Essentially, instead of a yes/no return of whether a tower is in a cell, I need the game to be able to know how many towers are in a cell, so if there is one tower, it adds a button to change from functions to towers, and if there are two towers, it doesn’t add the change button.
On top of that, I have to have certain 2nd tier towers allowable for each 1st tier tower. I’ll need to have a build list for each 1st tier tower, and I’m not sure how to do that in the kit.
Unfortunately, I’ll need your assistance on many more objectives before we’re done, each objective altering the kit’s blueprints, and I wouldn’t mind compensating you if you guide me through your blueprints to accomplish my team’s goals until our project is finished.

Alright, so before going to the UI side of things, you will have to modify the base structure of the struct data arrays that contain information about all the grid generators & grid cells. The ‘Struct_GridCellData’ by default, can hold information about the Grid Vector, Tower Actor reference, & an enumerated type to hold the Grid Cell Status. You will have to add another Tower actor element to hold reference to the second Tower, & edit the GridStatus enum by adding a new entry to depict a cell that contains two towers.

Now, on the UI front, the Tower Build & Functions menu are constructed dynamically based on the information specified in the Tower Data Array & Tower Functions Array [both stored within the Game Instance class]. The ‘Widget_TowerConstructor’ class houses the logic for the same, & you can add custom logic at the end of the ‘CreateTowerBuildButtons’ & ‘CreateTowerFunctionButtons’ to add your new custom Change button widget. At the start of these functions, you will have to add extra code to get ‘SelectedGridGeneratorIndex’ & ‘SelectedGridCellIndex’ from the player controller class & then the data associated with the corresponding grid cell from Grid Manager. Based on the grid cell status thus obtained, you can determine whether to add the aforementioned Change button or not.

As mentioned previously, you can use the Grid Cell Status to accomplish this. The ‘ManagedSelectedActorInteraction’ function in Player Controller evaluates actors selected by the player & determines what to do based on that. So you can use the Grid Cell Status here to ensure that the Tower Functions menu don’t pop up when the player clicks on the base tower in a grid cell that already has two towers.

As for the ‘Repair’ ability, you can modify the ‘Event Repair Armor’ interface function in the Parent Tower blueprint to first get information about all towers in the associated grid cell from the Grid Manager, & then apply repair logic to both towers in the cell.

The toolkit does not support multiple upgrade paths for towers by default. So this is going to require quite a lot of changes. I’ll get back to you once I figure a good way to approach this problem

I’d rather keep it going as part of the product support process. I may not be able to provide detailed screenshot based workflow as the required features start straying too far away from the base design, but I can guide you in the right direction in order to make the necessary modifications.

Alright, so I have some ideas on how to go about adding multiple upgrade paths for towers. But before proceeding further with any solutions, I’ll need to know what type of model you are exactly referring to:

  1. Is it more like Kingdom Rush, where each base tower has a standard singular upgrade path, but provides a specialization option at the very end of the upgrade tree?
  2. Or are you trying to implement an open system, where each upgrade level offers a set of choices irrespective of the upgrades chosen prior to it?
  3. Or do you want the upgrade system to start out with multiple trees, but then locks down a single path based on the first upgrade choice?
  4. If it’s something else, maybe share more information about the design specifications.

As an example, if we build towers A, B and C as base towers and towers E, F, G, H, and I as secondary towers, we need tower A to only have E, F or G be able to be built on top of it. Tower B only allows tower G, H or I on top of it, while tower C only allows E, G and I.

The more immediate problem involves the team’s design for the laser tower. It has a double-barrel cannon which came up with three problems. The laser tower didn’t have much script for having a mesh track the target, which I was able to solve and works well. It didn’t move the origin point of the laser once it began firing, which I was also able to solve. When I tried to fire two lasers from one tower though, it crashed the engine.