[SUPPORT] Advanced Turn Based Tile Toolkit

Hi and thanks for your work,

I bought your toolkit yesterday because I thought it would be the perfect starting point for my project. I always wanted to make a digital version of an idea I had for a board game and when I starting looking up methods and possible tools I found yours. The core of this game would be a square grid of fields which could be occupied by a player (similar to the game of risk). Each turn a player has some points which he can spend to expand his occupied area(this could come from the movement cost system somehow I guess). The game is supposed to be played only by real players via network as I don’t think I’m able to incorporate a AI right now. At first I thought I wouldn’t have to change too much but I think I’m getting a little bit lost. Sadly I just started working with UE4 so a lot of my problems should clear up by reading and learning more about it and about your toolkit too. But I’m asking right now mostly to hear from you if you think your toolkit is the right starting point for my ideas and if you think the changes I would have to implement are feasible.

My standing right now is that I need an array with the positions of occupied tiles of each player(the grid unit array seems to be a good starting point). From this a further array for each player is determined which includes the locations of all reachable tiles(mostly neighboring tiles) and which tiles have to be filled first(a player is not supposed to just build straight lines of tiles but should have to "reinforce a line of tiles after a determined length*). Those arrays should at each turn be compared to see where a possible tile is a hostile tile.
There would be three possible states of a tile in game then other than the default state. Possible, must-be-filled-first, possible but hostile(attackable). The arrays would also need to be updated each turn.

I thought about having a unit for each player that will stay for the whole game on the starting position. I would change the click actions so that clicking a tile would trigger filling a tile if it’s possible and doesn’t require another tile to be filled first(and you have enough points) or trigger an attack on a hostile tile. I don’t know exactly what the ā€œfillingā€ part should be. Of course it should change the entries of the arrays. After that it should be enough to represent the changes just visually on the grid I think as I don’t need animations or having the filled tiles act independently in any way - I first thought about filling it with units. I’m not sure how to get there exactly.

This would be my base idea. I have some extensions in mind like different rule sets(the players start with the same rule sets but after reaching some special tile they can choose from 2 or 3 advanced rule sets). The grid has tiles with differing costs. The grid layout I’m thinking of would allow 4 or 2 players - this should be determined before a game starts…

As I’m seeing it your grid system, the turn system, the networking system(without understanding them well) are a very solid starting point. The problem is that the toolkit seems to me to be focused on the units with stats and abilities which I don’t need. Do you think it’s possible to build it into what I need?
I guess I could answer a lot of this myself by understanding your toolkit better but I have some problems with the tutorial videos - mostly with the one about blueprints - because it looks like a lot has changed.

Sorry for this wall of text - at least I hope it’s understandable.

*I’m thinking that when a player is active all possible tiles(because of neighboring) are shown. But when he hovers over a tile which would make a straight line too long it shows in a different color which tiles would have to be filled first. (I hope I explained that understandably) - logically this would mean to check starting from a tile with only two neighbors if those neighbors too only have two neighbors and if this is true for too many consecutive fields you would have to fill in a third neighbor for the first tile with only two.

The first image is the original BP_Unit_Anim as that’s the one triggering the error for some reason. This is only happening with my custom character so I’m pretty sure I’m messing up the blueprint somewhere. The second image I posted is what I’m currently using in the Anim_BP for my new character and I’ve tried to copy the BP_Unit_Anim and switch the Cast To over to the Anim_BP that I want to use, but I get an error saying that it’s not compatible. Hopefully this is something really small that I’m missing from lack of knowledge. Here’s a screenshot of when I try to switch the line from going from the original cast to the ā€œsetā€ to my new Anim_BP. I feel like I’m just putting things in the wrong place here lol

Hi, I’ve not seen this issue before. It seems like some of the blueprints that are initialized at startup are being initialized before the grid manager is accessible, but I don’t know why. How are you loading your level? Is your main menu level a separate level? Have you made any changes to any of the startup events for the core blueprints in the toolkit?

Hi izckl, generally I believe my toolkit is a pretty good starting point for any turn based games on a grid; especially for ones that involve moving pawns. Unreal Engine takes a while to master and using ATBTT adds more stuff to learn on top of that. If you have not done so already I would recommend at least going through all of Epic’s official blueprint tutorials. From what I can gather from your post I think the game you are describing is feasible and should be doable using the toolkit, but it will of course be a challenge.

If which tiles are owned by which faction is central to your game I would recommend you create a new Map type variable with integer keys and EFaction values. This should give you the most control. The grid units map is a bad idea to use, as you need this to hold the location of units, and since the values all need to be references to actors placed in the levels, which is impractical in your case. You can use maps or sets of integers to hold tiles that are to be converted. For your various states you can use a custom enum.

Sounds reasonable enough. Like you suggest, filling a tile would amount to altering the appropriate value in an array. Displaying this can be done however you want. I would not use units just for displaying whether a tile is filled, since you would not be using most of the unit features. You could simply spawn static meshes (instanced or otherwise) or anything else, really. How do you imagine that ā€œfillingā€ would look in your ideal game? All the mechanics for interacting with tiles could be handled by a custom BP_Ability, which would hold a lot of your gameplay code. Having a unit for each facton which uses this ability sounds like a simple way to do this.

Ok. Changing the rules could always be set by changing a global variable (possiblity in the turn manager), which your custom ability uses to inform what actions can be done and what happens at the start of a turn.

As I said initially, I believe my toolkit is a pretty good based. It is true that there are more features included for games with units with stats etc., but I have tried to make the toolkit as flexible as possible so that it can be used for many different kinds of grid and turn based games. But of course the further you move away from the included examples the more work you will need to do on your own. I apologize that most my tutorials are somewhat outdated at this point. I will be making new ones, but it will take some time. Since you want to make a networked game, going back to an older version of the toolkit is not an option, unfortunately. Feel free to ask anything you are wondering in this thread, however, and I will do my best to help you.

No worries, I think I understand most of it. If you need help with specific implementations of features I would need to get a more detailed description of my mechanics, but I think I understood your mechanics enough to give you a proper answer.

Not sure if I understand this one 100% what is the starting point of the path? By straight line do you mean a line that is straight like a ruler? With the regular pathfinding you could at least check all the grid indexes of the path and compare them to your new faction map.

Hmm, odd. I added a new unit to the toolkit using a custom skeleton while trying to figure out what might have been wrong on your end and I did not experience any issues. Maybe I forgot to describe some small, essential step. Like I said, it seems the problem is that the reference is not being filled for whatever reason. What is the compatibility error you are getting? Have you changed the class of the abpref variable to your custom one?

[quote=ā€œ, post:2042, topic:21930ā€]

Hi, I’ve not seen this issue before. It seems like some of the blueprints that are initialized at startup are being initialized before the grid manager is accessible, but I don’t know why. How are you loading your level? Is your main menu level a separate level? Have you made any changes to any of the startup events for the core blueprints in the toolkit?

Hi! I didn’t make any changes to the toolkit and did make a separate lvl for the menu. This is a Level blueprint of that level and Widget event Graph.

I tried replicating your blueprints and it is working on my end. Made a separate level for the menu, added a widget with a start game button to the viewport from the level blueprint and run OpenLevel(Example) on click. Might it be something in how you set up your level? What happens if you load my example level instead? Are you playing in standalone?

Hey OperatorCrux, I had the exact same problem.
I did however manage to get passed those error messages, but I’m stuck somewhere else now.
Maybe I can help you with this specific problem, since I struggled with exactly that for a day.
I will try lend you some visual aid maybe that will help. Basicly it’s the same advice already gave.

In the animation blueprint (mine is called ABP_Custom) check your class settings, and add the BPI animate unit interface:

After you checked that make the following changes to your custom model (mine is called BP_Unit_Custom): add a variable, just like abref, but called abref2 or something, refering to the object ā€œABP_Customā€ (but ofcourse take your animation blueprint). Change ā€œcast to ABP_Unitā€ to ā€œCast to ABP_your ABP nameā€. After doing that add a new ā€œAnimate Abilityā€ and "Animate Movement "(uncheck context sensitive or it wont show up!).
I basicly highlighted all the key differences in the next screenshot so you can figure out what part you need to change. I hope this will help you along, goodluck :wink:

Thank you so much. What i was messing up was the way that I was declaring and setting the variable. I wasn’t specifying that it was a reference to the Object Type so it was just routing back to having no reference at all. I was completely overlooking the details panel when trying to change everything around to reference the new stuff. Here’s a screenshot of what I did for anyone else who might be searching this thread in the future looking for a fix for the same issue.

Thanks again @ and @Phoidy

Thanks for posting what you did, Crux. That is basically what I tried to explain in my post. Only difference is that I changed the class of the reference instead of creating a new one, but the results are of course the same. What are you stuck on now?

Glad that solved it for you. Is everything working as expected now?

Hi,

I figured a lot of things out since my post from saturday. I think I understand the toolkit much better and already began trying to build my ideas into it. As said I want to do a board game. Different tiles will be assigned different states in the course of a game (for example controlled by player 1 or 2 and so on…). For that I initialize a map with grid indeces as keys and integer values corresponding to the state. From a custom ability I call a function in the grid manager that updates this map - when a state changes. In the Ability-BP where possible targets are determined I changed it to output a set of indeces according to my needs. And in the animate actions part of the Ability-BP I changed the meshes which are supposed to be shown at the possible target indeces. Just to give you a short overview of what I changed. But I don’t know what could be responsible for my problem: I tried to print something out after the branch which checks whether the unit is ai controlled and that one gets printed. After that the event Player Activate should be called but the string which is supposed to be printed directly after the Player Activate event doesn’t show up. What could be the reason the event doesn’t start? There is nothing between the two Print to Stings other than the event call and the event.

I tried connecting the execution path (if that’s what you call it) coming from the ai check branch to the first node in the Player Activate part and then the meshes are shown on the correct tiles. But I guess there is a reason this is not directly connected that I’m just not seeing?

Edit: I made my additions in the same project in which I started fiddling around with it. Maybe I changed something without knowing it. Is there any easy way I could export my own functions and everything I changed without building up everything part by part again?


I was able to go on while connecting the the Activate and PlayerActivate parts directly in the Ability Blueprint. I made a new event which fires simultaneously and goes to the specific abilities (I guess that is the reason there is no direct connection in the ability bp?).
But while I am now able to spawn my markers by clicking the rules I tried to implement to check which tiles should get a marker when clicked and which shouldn’t
don’t seem to work. I think it is because my array/map located in the grid manager doesn’t get updated properly. I am making changes to the map on every turn (I want to be able to click several tiles in one turn later - depending on AP) in the ability blueprints and I want to access the changed map in later turns. Is there a principal problem with that or would that be possible if I do in the right way?

Thanks for helping!!

I guess with Crux you mean me :wink:

I’m happy to hear it was helpful for OperatorCrux.

I’m still stuck with getting my custom characters to move:
I made a blendspace (1D) with the same specs as the ones you use (speed 0-600, idle, walk and run at the same position, preview works fine).
What i see now when I move a character is they are in idle animation (so the first part of the blendspace works), but they slide to another location instead of walking.
Somehow the walking part of the blendspace isn’t triggered or there is a problem in my ABP somewhere.
I haven’t worked on it for a few days, but I will dive into it again tomorrow.
If you have any suggestions I’d love to hear them :slight_smile:

Hey, sorry for the late reply. Adding a print string should not break any execution chains, so I don’t really know what is happening here. Are you modifying BP_Ability directly? If you are using a child blueprint of BP_Ability which overrides PlayerActivate then the PlayerActivate nodes in BP_Ability will not trigger. Where exactly are these print string nodes placed?

Oops, sorry. Swapped the names out while typing. Hard to know what part you might be missing as you seem to be doing all the steps that I did and which work on my end. Perhaps try deleting and re-adding a couple of things so that you know that the correct references are being used? In your custom unit blueprint make sure the MulticastMoveAnimation calls the Animate movement interface function from the correct reference. Make sure it is the interface event that is called and not something else. Ensure that the abp was compiled with the interface added before adding the call to this event. Try printing the input and output of the speed variable and see if it has the correct value. In your animation blueprint, check your blend space and make sure that the animation changes appropriately when you alter the balue within the timeline. Check that you are using the correct blendspace within the state machine and try deleting and re-adding the reference to the speed variable in the blendspace. That is all I can think of now as, like I said, you seem to have done all the right stuff, and it works for me.

I’m happy to report I was finally able to fix this problem.
Ofcourse now that I found it I feel like such a noob, but I will report it anyway in case someone is wondering:
In the event graph of my custom ABP I had a wrong event casting to the speed variable.
I changed the custom_event_1 to the Event Animate Movement and it worked right away.
Some screenshots to clarify included

Thanks again for your help ! your suggestions were pointing me in the right direction.

Glad to hear you fixed it. Whenever I spend hours trying to fix some bug it is usually always some small thing like that. That is why I asked you to check if it was the interface event that was called and not something else. I’m guessing what happened is that you copied all nodes, including interface events, from an actor that implemented the interface to one that did not do so yet. Since UE4 could not find the interface it created new event nodes instead, which will of course not be called by other actors attempting to call the interface.

I made a new project with an empty level of the toolkit and a menu that you could look at.

This is google drive folder with that project so you could check
https://drive.google.com/drive/folders/1y3UTMcbLfNg8qMeQOLabz-hhGAe4egGU?usp=sharing

I also made a video capture of me doing that

Ah, I see. I misunderstood the trouble you were having. The reason you are seeing this error is because the default game mode in the config files of a fresh ATBTT project is BP_ATBTT. BP_ATBTT has an event begin play event that looks for the grid manager. To stop this error message from occuring modify BP_ATBTT so it does not run all its EventBeginPlay nodes when it spawns, but rather from a custom event you can trigger when you want.

Hi ,there is a issue i found in "Find Overlapping Tile Locations"function. ā€œstart locationā€ is a world location, and you forgot to turn it to relative location. may be we can use the third picture.By the way , This toolkit is so cool, i love it very much, thank you for your hard work and tutorial. last , please forgive me ,my English is not well.

Hi , I’ve finally saw your splendid work on advanced AI, congrats for that.
In our game, the main character, AI or human, starts alone and then he has to spawn servants to gain mana and tactical advance.

Should I considerely disrupt your AI system to achieve that? Or simply put an additional ā€œis main character aloneā€ in the head of BP_Ability Ability Assesment flow should work for that?

Hi ,

Firstly, thank you for taking the time to create this toolkit and for also creating some very informative videos! For a novice with UE4 such as myself, it has actually been an invaluable teaching resource for my working on RTS and Simulation-type games.

I just have a question, though, and it is regards the 2D dungeon crawler project. How have you managed to distinguish walls and other obstacles from the rest of the tilemap? My understanding of Paper2D is that you can’t query individual tiles in such a way to do this neatly.

Cheers,
Kieran

Thanks for the kind words. The AI system is one of the things I have spent the most time on and it is somewhat hidden since I have not had the time to make a video delving into it yet.

You could achieve the effect you want in the way you describe it. If you are not using the advanced ability component used in the JungleRaid map this is the way to do it. However, if you want to do it closer to how I intended it I would use the ability system component and create the spawn servant ability as a separate ability. In the evaluate ability event for this ability you can calculate whatever conditions would make the AI consider spawning a servant to be more or less valuable. Then you would return a value between 0 and 1 based on these factors (maybe look at the heal ability for the simplest example). If the spawn servant ability is in the ability array of an AI unit’s ability system component it will consider this value against the values of its other ability and select the best one dependent on the situation it is in.

Happy to hear that my toolkit can also be useful to people making different genres of games :slight_smile:

For the 2D collision thing you should take a look at the tilemaps. Tilemaps can have multiple layers and it is possible to define a collision thickness for each layer and to specify which tiles should have collision. For the 2D example I have made it so ground tiles block pathTrace to indicate that they are walkable, while wall tiles block wallTrace. When using my procedural system for generating a walkability map (by setting heightmap and bTraceForWalls to true in the public variables of BP_GridManager) this gives the result you see in the 2D example map.

Whoops, I did not see your comment until now for whatever reason. Sorry. Thanks a lot for reporting this! I will look into it and fix it.