What would be the best way to dynamically spawn units for the player. I have a menu system that allows the player to select their unit types but I cannot figure out where the best place/way to dynamically spawn the units and have them snap to the grid made by the grid manager. I can spawn them but they are not part of the tool kit. Please help, I will continue to look for the solution as well and If I can will post the solution to the forum once my pc stops being dumb.
Thank you in advance.
—End Quote—
The following is from and worked great to solve my issue. Thank you.
Hi Imonin, sorry about the silly computer. The important thing to understand about the toolkit is that everything important is happening within arrays, and all actors, such as tiles and units, mostly exist to display the current state of the grid to the player. For instance, the grid doesn’t “know” that a unit is placed upon it, only that a certain index of the grid (corresponding to a location) is set to a certain value. So to add a unit dynamically you cannot simply spawn a unit actor, but must also add that actor to the appropriate arrays. For units that means the Pawn Actor Array (where you add a reference to the actor itself) and Pawn Array (where you add the faction of the pawn) inside BP_GridManager. This means that you must use the Set Array Element on the appropriate array on the index corresponding to the pawns desired location. You also need to add the unit to the initiative order contained within ATBTT_GameMode. I have made some utility functions that will add to
the next patch that do precisely this. This is a function contained within BP_GridManager which can be called from whichever blueprint that has a reference to the grid manager. Here’s the function:
Image: http://i.imgur.com/OTD3074.png
and here’s an example of how it can be called in ATBTT_PlayerController if you want to add a pawn to a tile you are currently hovering the mouse over by clicking ‘1’:
Image: http://i.imgur.com/SMBBO1O.png
Hope that helps!