[SUPPORT] Advanced Turn Based Tile Toolkit

@Mariyan: Hi, there have been a few other users who have asked me similar questions before, so look at the previous couple of pages for more info. Setting the order in which pawns are selected is pretty easy. All units are stored in the Initiative Order array in ATBTT_GameMode. Like mentioned the code for selecting the current pawn from this array is done in the event graph of ATBTT_GameMode. Have a look around it and it should hopefully become clear how this is done.

For an in Depth explanation see my fifth tutorial video (which kindly linked to) and click the link in its description to ATBTT_GameMode. Units are sorted in initiative order in the Sort Pawns in Initiative Order function (or a similar name. I cannot check until next week when Iā€™m home). To make Your own function, add them to the array in the order you want them to be activated. All this is the easy part, while the tricky part is to make several changes to the toolkit to allow for multiple player factions. I have discussed this in more detail in earlier posts, but the main thing you will need to do is to change functions such as Pathfinding and Find Tiles in Range (both in BP_GridManager) among others so that they look for units of all opposing factions, and not just the enemy or player faction as it is currently done.

This will take quite a bit of work to get right, so I recommend that you have a good overview of the toolkit before you start. I recommend watching all my tutorials and working on some other parts of your game first until you know how most stuff works.

@Mopperl: Hi there. The toolkit does support 4.8, so Iā€™m uncertain what might be causing your issue. Like Iā€™ve mentioned this sort of thing happens when a false value is returned for some of my blueprints. Are you using the 4.8 Version of the toolkit, or an earlier version converted to 4.8? I would recommend uninstalling the toolkit, downloading it again from the marketplace page (make sure to select 4.8) and creating a brand new project with the toolkit using the Create Project button next to the toolkit in the vault. Hopefully this should resolve you problem, as it really should work out of the box with 4.8. If it still doesnā€™t work let me know, and Iā€™ll think on it some more.

@, : Hi, thanks for your advice, much appreciated :).
Regards

Yeah my bad, it seems to have been the whole converting to 4.8 of an older version that caused the issues it all works fine now :slight_smile: Thanks!

No problem!

I actually set mine up a little different than what suggested. Ended up leaving his Pathfinding and Find Tiles in Range functions alone and just set everyone except the Player as Enemy Faction, then created my own Faction/Team Enum for UI/Game Rules/Abilities/Etc that is set as a new variable on Unit Parent to reference later when the Pawn is placed on the Grid.

My main intention here being that I wanted to keep my hands clear of BP_GridManager for any future updates. Grid Manager holds all necessary logic for the grid itself, so keeping it pure is always good imho.

Also, just in case anyone was wondering how to add or place a unit on the grid during runtime, this is how I set mine up (Thanks to for the assist in IM a while ago):

Basically it accepts a Unit Parent Class (What someone selected in the UI), the Index Tile in which to be placed on, and in my example I am converting from my custom faction list (which will be expanded on later) to the GridManager accepted Faction Enum. Once it creates the Actor and sets its values correctly; it adds that Actor to the proper GridManager arrays for the Grid Logic. The Unit is also getting returned in my function so that I can set some other values in the UI/GameMode after it has been created.

Side Note: If you are using the ATBTT_GameMode and you still want to utilize the Initiative order, you would need to add the ā€˜Local Unit Actorā€™ to that array as well.

Hi All

So apologies in advance - Iā€™m a noob with Unreal and hence the ATBTT. Having skim read the forum having some issues with getting the toolkit up and running. Iā€™m running a fresh install of 4.8.3 and recently purchased the toolkit. Have watched all of the videos (which convinced me to buy the toolkit) and seem to have the same problem that a number of people have occured, inasmuch that when pressing play after setting up the grid (hex) with a couple of actors, control seems to be passed to the camera and not the player.

@: Firstly, this is a great piece of working and we cannot wait to start using it. Having used numerous engines (both custom and commercial), I really do think youā€™re going to see some amazing work coming out with your toolkit. Apologies again as it appears that youā€™re answering noob questions again but any help would be greatly appreciated.

@Mopperl: Good to hear that was the issue. I had a hard time seeing what else it could be. I hope youā€™ll have a bug free experience from now on :slight_smile:

@: Thatā€™s a pretty clever way to add the new functionality easily without modifying too much of the core toolkit. Thanks for posting a screenshot! That will hopefully be helpful to Mariyan and others :slight_smile:

Edit: @anonymous_user_c4ef34dd: Hi there! Have you tried following the suggestions I gave to users who had similar problems? Try uninstalling the toolkit, going to the marketplace and downloading it again (making sure you have the 4.8 version selected). Then click the Create Project button right next to the toolkit in the vault to create a brand new ATBTT project (do not try to add the toolkit to an existing project, as this does not work out of the box, and requires some tweaking). Then try to play the example map in the editor and see if it works. If that doesnā€™t work Iā€™ll try to think of other possibilities, but itā€™s what has helped other users before.

Donā€™t you need also to add the new spawned unit into the initiative array?
Thanks for posting the above, anyway :slight_smile:

Read the side note in the post :slight_smile:

If you are using the Initiative order for ATBTT_GameMode then you will need to include the unit in the Initiative array. I am using my own custom GameMode that does not include Initiative order, rather only by player selection of units and an end turn button to switch to different team turns. (This is mostly because I setup a ā€˜Hotseatā€™ type mode that requires you to end turn in order to switch to the other players units.)

Hope this helps!

I was just wondering by watching the blueprint and without read the side note :slight_smile:
Probably I will use a similar function to spawn units after a network match has been successfully created, and also it could be an help for a ā€œspawn minionā€-like skill for my troops.

As I promised to , when I will collect some working code for multiplayer implementation with GameSparks I will post here :slight_smile:

Thatā€™s exactly how I am using it :smiley:

Select Unit/s in UI -> Spawn Units to grid at specified placement -> Allow abilities to spawn minions.

In the blueprint for spawning units I sent to some weeks ago there was also a part that added the unit to the initiative order array. This was a work in progress of a function Iā€™ll be including in the next update, where I will also include some other utility functions.

Iā€™m excited to hear that youā€™re still working on the multiplayer implementation, Wisdom_HELLy! Canā€™t wait to see what you come up with :slight_smile:

Hey there, sorry if this has been previously brought up but im wondering how to spawn units into the game without placing them in the level first?
Like choosing what units you want before game starts and then spawning in
I have tried this way but the unit can be interacted with or moved,

Hey . That same question was asked on the previous page of this thread, where pasted a modified version of a function I sent him some weeks ago for doing just this. Iā€™m finally back home, though, so I can finally post my own current version. Here is the WIP function for spawning units at runtime (BlueprintUE link):

It still has a few small issues, but itā€™s mostly complete. Iā€™ll explain what it does. First it spawns an actor of the Unit_Parent class (the specific one is specified outside the function) at a certain location. The user can choose to either spawn the unit at an index or a transform. If transform is selected the location of this transform is first run back and forth through the VectorToIndex macro and the Vector Field Array to return the location of the closest grid cell center to the transform entered (donā€™t want to spawn the unit between two tiles). Then the index value of the actor is set to the index of the tile it is spawned on. After this the unit is added to the Pawn Actor array and its faction to the pawn array, both at the index of the tile it was spawned. Lastly it is added to the initiative order, or it will never be selected. This always adds the spawned unit to last in initiative, and might cause issues if you allow switching between units (the default toolkit assumes players and enemies will have distinct turns, which might be altered if you alternate adding enemy and player units).

The way you have done it has a few issues, and Iā€™ll point them out so you can understand the inner workings of the toolkit better. When you add the unit to the pawn actor array, what you are doing is increasing the size of the pawn actor array by one by adding the unit to the end of it. The Pawn Actor array is the size of the grid with each index representing a grid cell, so if you add a unit to the end of it it will be placed at the last tile index +1, outside the bounds of the map. Instead you should use the Set Array Element node and set the index corresponding to the unitā€™s location. ā€œHas acted this turnā€ defaults to false, and so you do not need to set this to false when spawning a unit. Place actor at anchor and ignore snap to custom grid are variables that only have an effect when youā€™re working on the game in the viewport, and not when youā€™re actually playing the game, so modifying these at runtime serves no purpose. Lastly if you always want the max move of the spawned units to be 4 you would be better off modifying the default value of this variable in the unitā€™s own blueprint.

I hope this helps you with your problem. And congratulations on reaching your Kickstarter goal :slight_smile:

Awesome this really helps :slight_smile:
Thanks for taking the time to explain it all
Yeah im really happy it got funded, now iv just got to work hard towards an amazing game!

Hey there, Im starting to implement my AI and change whats currently there to suit my game.
Thought I would post it up here incase other people are wondering how to do the same/similar things.
There are a few things I would like to cover at some point (Making AI search for things other then a player, Factions that can wander around without attacking player, Multiple different factions on one map)
For now though I would like to sort out the former.
I have set up a basic pick up duplicated from a hex tile, It works as when a unit walks over it, it randoms a number between 1 and 3, depending on that number you get +1 to one of your resources.
I would like to set it up so the AI would also look out for these tiles and go to them if they are closer then the player/if they arent attacking the player.
From looking at the AI controller, iv determined (ish) that I would need to either: Add in some extra functionality to Pathfinding, Find Tiles In Range or adding more variables to the pathfinding struct to take specific tiles into account.
How far off am i?
Thanks

Hey ; Probably the best thing you can do is add a boolean check to the Tile_Parent, something like ā€˜Has Consumable?ā€™, and set it to true if it contains one. Then after the Find Tiles In Range check that you are doing in the ATBTT_AI_Controller, you can loop through all of those tiles and check if it ā€˜Has Consumable?ā€™ and check if the Tile ā€˜Distanceā€™ is shorter/further from the closest/furthest Enemy Faction by looking through the Pawns in Sight Array or Reachable Pawns Array.

@: that would be a good soluting, but unfortunately the Tile_Parent actors are not stored in any grid sized arrays, so you cannot find them by using find tiles in range. For your solution you would need to look at every Tile_Parent actor in the level and compare its index to all the indexes outputted from the Find Tiles in Range function, which is not very efficient. I know it sounds like you should find specific tile actors when you use ā€œFind Tiles in Rangeā€, but what youā€™re really finding are tile indexes. The way the toolkit works currently there are other solutions that would be better. What Iā€™ll be suggesting should do is still pretty close to what youā€™re suggesting.

@: Youā€™re on the right track. There are of course many different ways to do this, and which is best will depend on a lot of factors. When searching for enemy units to attack the toolkit does this in the Pathfinding function, adding units to an array every time a unit is found on a reachable tile. Then in ATBTT_AIController the AI looks at all these units and finds the unit of faction player with the lowest health.

I would not do the same thing for your resource tiles. This would be have to be done in the innermost pathfinding functions, and adding to these is a quick way to slow pathfinding down considerable. Instead I would create a new child actor of Tile_Parent for your resource tile. After pathfinding I would look at all actors of this class in your level and check the indexes of CanMoveToArray (in BP_GridManager) corresponding to the index variables of the actors. If these indexes have costs higher than 0 it means they can be reached (you should also check that PawnArray on that index is empty).

I would then store all such candidates in an array to compare them later on. In ATBTT_AIController you can use a function similar to the one I use for finding the unit with the lowest health for finding the resource tile with the lowest move cost. You could then compare this value with the move cost of the CanMoveTo Array cost of the index of the target pawn, and move to it if itā€™s lower (if this is how you want the AI to act. Iā€™m not entirely clear on what conditions you want for the AI to decide against attacking).

Hope that helps as a start. This is a bit tricky to accomplish, so feel free to ask for clarification.

Hey there, thanks for the feedback but yes as you suspected I do have some questions.
Am I to be doing this in the AI controller or Grid Manager after Pathfinding?
I have created a child as you suggested and moved the tile functionality into there.
After Pathfinding I call a Get All Actors Of Class - Tile_Hex_RandomResource.
This is the bit im less sure about, am I dragging off a GridManagerRef and getting the CanMoveToArray?
Well anyway I cant see a way to get the indexes of the Array or the Tiles thats where im currently stuck.

@: Yeah thatā€™s kind of what I meantā€¦ Use the Tiles in Range Array to ā€˜Getā€™ the Tile Index through Find all Actors of Class Tile_Parent; It has been a long day of messing around with Tile Index/Distance to get custom Attack Markers working, so Find Tiles In Range is on the brain lol