[SUPPORT] Advanced Turn Based Tile Toolkit

Something like this?

My Player activate :

My Show Build Markers function:

Click function

When I click on a “Build Marker Tile” my print function in click never gets called. Do you see what I did wrong?

Hello chriscast. I’ll do my best to answer your questions.

Someone mentioned the same problem a couple of weeks ago, but the problem disappeared when they made a fresh project. Try creating a fresh 4.20 ATBTT project and see if it solves your issue. I do not see this problem on my end.

Tick is disabled on units by default for performance reasons. If you need tick to be enabled for your custom functionality you need to set actor tick enabled to true in the settings of the blueprint class. Also, I would not recommend using BP_Unit_Anim_Auto. It is a blueprint mostly made to quickly set up testing levels and not much else. I’m considering removing it since a lot of users are using it as a base, which is understandable as it is used in the example map. For customizing units I would recommend to make a duplicate of BP_Unit_Anim (unless you’re doing units without a skeletal mesh, in which case making a new child blueprint of BP_Unit might be simpler).

I’m in the process of creating new video tutorials for the refactored toolkit. As you mentioned, using 4.18 will let you more easily make use of the original tutorials, but there are some trade-offs to this. For instance if you want to use networked multiplayer or multi-tile units you will need to use the newer version. Also, the newer version is designed to be more flexible in general, so you might find it harder to add new functionality to the old version, especially if you’re doing something unorthodox. Additionally as time goes by my memory becomes gradually more hazy as to how things work in the old version and what was changed, so my support for the old version might be somewhat worse. I have made quite a few new tutorials on the new toolkit, though (about four hours worth, I think).

I intentionally had these tutorials cover the things that have undergone the greatest changes from the old to the new version, so if you watch first the old and then the new tutorials you should have a good overview of almost everything the toolkit does. I realize that this is a lot to sit, through, and my plan is to make several beginner-friendly tutorials for the new version when time allows. However, I have a deadline hanging over my head for work until Christmas, so my time before then is limited. I think my tutorials now mostly cover everything, but the new ones which have been uploaded til now are pretty dry and require that you have a good handle on blueprint basics to understand them.

So all in all I think I would recommend using the new version at this point, and ask in this support thread if you run into anything the tutorials don’t cover. I hope that sounds reasonable to you.

Ok, there are a couple of things here I see immediately and other things I’m less clear on. Firstly it is not good practice to find the clicked location in the build locations as you do in the interact event. If you’ve watched my tutorials on the Action System, it is best to keep the server-side grid logic separate from the client-side display of what happens. So you should try to keep the stuff happening in ServerInteract to grid indexes (which are coded as integers) and no check actual in-game locations if possible. Not saying the opposite would not work, but this way is less likely to have unwanted side effects and will generally be more efficient. In this case I’m guessing the problem is that the ClickedLocation you’re looking for in your BuildLocations array represents the actual location clicked under the mouse, which is unlikely to be in the exact center of a tile, while the build locations (which you got from the GridLocations TMap in BP_GridManager) are all in the center of the tile. Unless you click exactly in the tile center (almost impossible) the branch will never return true.

So the correct way to do things here is to both build an array of location to use for your DisplayBuildTiles QueueAction, but also make an array of indexes to check in the SeverInteract event (or really a Set, as they are more efficient to check using Contains).

Ok, that is the most obvious thing, but other things are less clear. You say the print function never gets called, but I cannot see a print function. Is it contained in the ExecuteAbility function? I assume your ExecuteAbility function here includes some sort of branch to check whether you’re trying to move or trying to build?

Ok so far so good.

I can now have 2 actions per turn for a player. One is moving and one is “Building” although the build action is nothing more then placing a static mesh on the clicked index.

I am having a hard time wrapping my head around the build action |-_-|.

"Subtract the Z location of each tile to the Z location of the center tile and get the absolute value. If it is below an arbitrary threshold you want to add edges between the tiles (if there is not an edge there already). If it is above you want to remove the edges (if they exist).

To add and remove edges is simple. Use the RemoveTileEdgeBothWays and AddTileEdgeBothWays functions in BP_GridManager. There are already checks in place to make sure a tile is not added twice. For these functions input the grid index of the center tile and its neighbor. The order does not matter. You want to use the “both ways” function, as if you only add or remove one way you will still be able to move one of the directions."

Can you maybe elaborate this some more how I would stack the meshes and add a tile?

edit: Ok stacking of blocks works now. I forgot to name the Socketname to get the Z value of the mesh :D. Need to figure out now how to get up on the block.

Ok I think I am almost there :

Hey, sorry it took a while to reply. Been busy. Good to see that you’re almost there. There are just a couple of small changes you need to do to get it working, as well as some less important suggestions.

Lets start at the left side of your graph. This is minor, but I think it would be cleaner to include the static mesh in your custom GridActor itself so you don’t have to add a component manually every time. Also, since you are not using the Box variable any place later (unless you have more stuff that I’m not seeing) you do not need to set that variable. Buy yeah, minor stuff.

The first real issue is for your MapAdd node. It works great the first time you add a tile (provided the grid manager is at Z location 0), as you set the grid location to 0 + the top of the box. However when you then add a new box on top of that one the new location stored at Z in the map will also be 0 + the top of the box, which I assume is not what you want. You want it to increment by the box height every time you add a new one. Therefore you need to add the Z location that is already there (which you have in your BreakVector node) to the socket location.

The next and final issue is when you check the height differences of surrounding tiles. Your last branch in the graph you linked is not connected, so will of course not work, but I assume you’re aware of this. You’re getting the correct height values, but I think you want to change how it is checked. I assume how you want it to be is that you can walk between two tiles unless the height difference between them is equal to or higher than twice the height of a box. So you don’t need two branches for this. After subtracting the height of the clicked tile index from the height of the neighboring tile use the “abs” node to get the absolute value (which does not care if the value is positive or negative). Use a branch and check if this absolute value is lower than BoxHeight2. If so, AddTileEdgeBothWays. If not, RemoveTileEdgeBothWays. Since the locations are vectors made up of floats their values are not 100% precise (a float of 0 might for instance really be 0.00001), so you should add a tiny bit of leeway in your calculations. Instead of checking if the absolute value is smaller than BoxHeight2, maybe check BoxHeight2-1 or something, or even BoxHeight1.5 if you want some leeway in the heights of your box meshes.

Edit: Checking the video you sent me on the board game you are basing this on it seems you want to be able to move down any distance, but to move up only one box. This changes my suggestion a bit. Instead of using absolute value you need to keep the information if the difference is negative or positive. Then when you get all the surrounding indexes, if a surrounding tile is higher than BoxHeight1.5 compared to the center tile you want to RemoveTileEdge (not both ways) with the tile index as the center tile as TileIndex input and the tile index of the tall neighbor as Edge. Then you want to do the opposite for the neighbor, using AddTileEdge (again not both ways) with this tile as the TileIndex input and the center tile as the Edge. If instead the neightbor tile is lower than negative BoxHeight1.5 compared to the center tile you do the opposite, with AddTileEdge for the center tile and RemoveTileEdge for the neighbor tile. Lastly if the difference is somewhere between positive and negative BoxHeight*1.5 you can use AddEdgeBothWays like before. Hope that makes sense.

Hello again!

The game I’m making will base it’s abilities on playable cards that will be discarded and drawn during the game. At first I was thinking I need to intertwine your toolkit with the CCG Toolkit (as I’ve seen you’ve been asked about earlier here in this thread). However, looking through your new tutorials, I’m starting to feel that the only thing that needs modification to get this functionality is the UI (playable cards instead of the box of abilities as is shown in the Jungle Raid map).

My first question is then: Adding and removing abilities from the AbilitiesComponent array, can this be done at runtime?

As far I can can tell, all the UI stuff for the cards will be client only (both due to how I want it and also since UMGs only exist on client if I’ve understood correctly).

I will probably think of more questions on this topic but this is at least the first one.

Cheers!

Yep, I’ve thought the same thing. A card system is basically just the ability system with a random number of abilities drawn from an array every turn which cannot be reused on the same turn. One of the changes I made in the last update was actually done with just this sort of thing in mind. Previously in order to have an ability accessible it had to be spawned at the beginning at the game (or at BeginPlay of a newly spawned unit) and then references assigned to these spawned abilities which were used by the ability system.

I changed this so that the ActivateAbility event in the player controller takes an ability class as input and not a reference and then it intelligently spawns a new ability or uses an already spawned one if it is accessible. This frees you from having to spawn all possible abilities that might be used during your game at the beginning (which in digital card games with random card gain effects etc. would need you to store a lot in memory).

Without checking I don’t this should require more than changing the array of ability class references in the ability system component at the start of a unit’s turn, though there might be some things I’m forgetting since I have not tested it myself. I think the ability bar might still make use of an array of hard references to abilities, which would prevent the UI from updating properly if you only use the array of classes. If so this is something I should look into changing in a future update. Let me know how it works out :slight_smile:

Hey :slight_smile:

I saw in this thread that you are working on a way to show the movement area for a unit like its done for XCOM.
(just a kind of outline around the move area)

Could you share the logic you are using to build that?
I would really appreciate that, so I dont have to reinvent the wheel :slight_smile:

Thanks!

Hey Robin! There are some experimental functions included in the current toolkit that I used for creating the outline effect I showed a few pages back. However that method was quite hacky and not very performant. I would instead suggest to use a post processing volume to create an outline effect. @elec2ron suggested this to me in this thread and I have since looked into how to get this working in ATBTT. I now have something that works great for flat grids, though it still needs some work for grids with height differences.

So first you need to add a post processing volume with an outline shader. The best one I’ve found is the one by Tom Looman (found here). Follow his instructions to create the post processing material and set up an unbounded post processing volume in your level that implements it. If you are using a flat grid your work is nearly done at this point. Just make sure that the meshes used to display tiles in move range are big enough to be completely flush with one another and enable “RenderCustomDepthPass” and disable “RenderInMainPass” in the meshes’ rendering settings.

If you use multi-level terrain this can look weird (though test it out for your game to make sure), especially if the tiles have height differences within the tile itself. If so you need to do some more work to make sure all the move meshes are perfectly connected with one another at all edges or you’re going to see holes between them. A way to do this suggested by @elec2ron is to use procedural mesh components. In the current method I’m using line traces to find the center points in height between adjacent tiles. This works great for some maps, but results may vary for multi-level grids depending on collision. It is also not terribly performant, though more so than my previous spline-based method. I’m working on finding a way to efficiently cache the height data to improve performance. But for now this is the best I got. Sorry for the godawful spaghetti, but this is very much a work in progress.

This should give you the following result. Note that whether or not you want the outline to be blocked by overlapping meshes can be adjusted in the shader.

https://i.imgur.com/abjc1vO.jpg

Hope that gives you the results you’re hoping for :slight_smile:

Hi

Im completely new to this but I have been messing around with this for a few hours so I thought I might ask for some advice.
Following your tutorials is great but a bit hard sometimes since some of them are old and major changes have been made since then, half of this is probably due to me not knowing the Unreal engine editor either :slight_smile:

I have started with a few small goals to try and get going.
First I want to get a simple mesh with some hills and walleys setup.
I follow that part of your tutorial but when I start the pawns float down to the base grid as soon as I move them.

Anyone know what I might have missed?

Second question is for the pawns themselves, is there anything special I need to think about when introducing my own units?
Plan here is to copy one of your units and change the mesh to a simple box like vehicle while disabling animations.

Hello , long time no talk. I see I have missed alot being away most of the year, and I have alot to relearn… I was reading a few pages back you are planning another big update after Christmas, I was wondering if it will be compatible if I start a new project with your latest version.
I know you are busy a quick reply is not necessary, now I’m back maybe other users and I can get the self-support on this support thread will reappear to help you out…Bah Hah…
Also Thanks for your latest video

Hi there! Sorry about the outdated tutorials. It is something I’m working on improving, but it is going to be a pretty long process. I decided fairly early that I would not compromise making the toolkit as good as possible in order to keep things consistent with earlier versions or older tutorials. The consequence is a few major refactorings that I believe have substantially improved the toolkit, but the consequence is unfortunately that the old tutorials become less useful and converting to new versions is sometimes a bit of a hassle.

In making new tutorials I have prioritized videos covering the new major systems which were not present in older versions, such as the action and ability systems. This is good for users who are already experienced in using the toolkit, but have not worked with that particular system yet. However, for new users who are trying to figure out how the basics of the toolkit work, these are less useful, and since these users are in some cases also new to Unreal Engine in general, they might have a bigger need for precise and up-to-date tutorials.

I still feel that making sure all central part of the toolkit is at least covered by tutorials in some way is even more important, which is why I have prioritized as I have, but I realize this is a problem and will make new tutorials when I have the time. The issue is that I have a major work-deadline hanging over my head that is sucking up almost all of my free time, so I will not be able to consistently put off time for tutorials (or really development) until after Christmas. I will do my best to make some tutorials before that, but I cannot make any promises. If you run into anything in the tutorials that is confusing and halts your progress, let me know here and I will do my best to help you out. It is also very useful to me to hear what things are not covered well in the current tutorials so I can make sure to revisit it in the future.

As for your specific questions, for the first it seems you want to use the toolkit’s heightmap system to automatically generate a walkable grid on top of a terrain mesh, is that right? If so the variables you need to modify is in the public variables of BP_GridManager; more specifically in the Procedural category. If you set the heightmap variable to OneLevel the toolkit should automatically use line traces to create a walkable grid on top of your terrain, as long as you have set up GridSizeX and GridSizeY to size the grid appropriately and placed the terrain to overlap the grid. There are many variables to tweak in the Procedural variables, including how high and low UE4 should fire line traces to search for terrain, how large the height difference has to be between two adjacent tiles for movement between them to be disallowed etc. Play around with those and come back to me if you’re not able to get the desired result.

As for introducing your own units there is not really anything special you need to do. The base unit, BP_Unit, is set up to work fine even without adding meshes or anything, so it works just as well if you add a box mesh or whatever you want to it. BP_Unit_Anim is a child actor of BP_Unit I have made as an example of how to use a skeletal mesh and animations within a unit and if you were making a unit with a skeletal mesh I would recommend making a duplicate of this and modifying it as you see fit. For something like a vehicle, however, I would create a fresh child actor of BP_Unit and add your meshes. Then you can look at BP_Unit_Anim for ideas on how to add specific stuff. One thing to keep in mind is to not have the meshes block PathTrace or RangeTrace in the collision settings of the mesh, or you will see some weird pathfinding and visibility behavior as the toolkit will think the top of the unit is the center of the tile it stands on, and its own mesh will block its line of sight.

Hope that helps!

Hey , it had been a while. Happy to have you back :slight_smile:

I might have been a bit unclear regarding updates. It is not that I have a new, big update planned for Christmas, but rather that I have almost no time to work on the toolkit until around Christmas, so that is the earliest could event begin to work on a new feature update, and if I do so then it will certainly be released several months after that.

I’m actually starting to be pretty happy with where the toolkit is at. Adding networked multiplayer and multi-tile units were the last two major features on the list I made for myself three years ago of things I wanted in the toolkit. Because of this I do not really foresee myself making any new major, transformative updates like I have in the past. New updates are more likely to consist of bug fixes, performance improvements and new example maps to demonstrate ways to implement more game-specific features. I might do some medium-sized overhauls for some of the sub-systems. The initiative system is for instance something I might want to make easier to modify, and there are some parts of the toolkit, such as the touch controls and edge-panning in that I have not touched in a long time and could use some refactoring.

Other than that I am (finally) planning to make my own turn-based strategy game. I will naturally be using the toolkit for this, and as I make a game I hope to be able to add stuff from the game branch to the toolkit branch as I go along. I think this might even be better for the toolkit in the long run than me simply adding features for some nebulous game as I will get a stronger feel for what stuff is most useful and needed during actual game development. Still, not something I will be doing until Christmas time.

To sum up, if you’ve previously been reluctant to use the toolkit because of a big update on the horizon I don’t really think there is a better time to start than now. I cannot promise that I will never again do a major refactoring, as I sometimes get jolts of inspiration and am unable to stop myself, but if that happens it is a long way off.

Thanks for the reply , it’s not that I am reluctant to use, I didn’t have time in the past 6 months, still might be a while before I start full speed ahead. I am waiting to see what happens with UE4.20 as I would like to use it for the project and still making some media.
Also good luck on your own game, if you need a hand with media, just ask and I will see what I can do. Good luck with your thesis also.
I signed up on the discord channel and that will be alot of help to everyone. Alot of nice people using your toolkit and a lot of excellent projects being worked on…Good job on this toolkit and update.
Will talk soon…

No worries. Thanks for the explanation.

My blueprint is now this: Build posted by Studder | blueprintUE | PasteBin For Unreal Engine

And I check in “CheckIfValidTarget” if the player can move to a tile or not.

I still have a weird issue though that sometimes when I place the second mesh next to a player the blue markers for this player gets on top of the first mesh instead of the second mesh this doesn’t happen if I place a second mesh that’s not next to a player. You are correct that the player can only move 1 mesh up at a time and can move from second mesh to the floor directly.

I tried adding the Z location of the grid location like I think you said :slight_smile: but that gave me some weird results. Resulting the marker being two times above the meshes.

Another thing I am having trouble with is figuring out how you can end the turn of the whole faction.

Following situation:

I have two players. Each can control 2 units in 1 turn. But they can only use 1 unit each turn. I had no idea to switch between units inside factions so it’s now an ugly hack to switch between units in a faction.

When I click on a unit if it’s the same faction then it’s switching to that unit.

Now what I want is when ever a player end it’s turn it should always go to the other faction. This works some what if use “End Entire Faction Turn” in the ReactivateActiveObject but this only seems to work if I don’t switch between units in a turn. If I switch between units in a turn and end a turn it is possible to go to a unit’s turn in the same faction which I don’t want.

You have any thoughts how to approach this?

Sorry to bug you but one other thing :slight_smile:

I want the player not to walk to another tile but to gracefully jump to another tile. I tried some attempts to do it in BP_Unit but I don’t know how I would get the ClickedIndex in there to know where the player must jump to.

Thanks in advance!!

Hi again, thanks for the help, I got the mesh working now, It was the heightmap setting under Procedural.
Dont worry about the tutorials, remember I am completely new to the Unreal engine and editor.

Now I will proceed to mess with all the other stuff, most likely Ill break it in all sorts of impossible ways :wink:

Hi , I bought this toolkit a while ago but just started going through the tutorials last week. I wanted to use this toolkit to create a tactics game that plays like a rogue-like (Pause the game and give commands but have movement and attacks function like a rogue-like). I see that there is a rogue-like example in 2D game but I want my game to be in 3D. I’ll let you know if I figure out a way to do this, but I wanted to know if you have any ideas or suggestions on implementation in the meantime.

Does this toolkit have an official Discord? If not can the creator (or a user) create one? :slight_smile:

Ok, I figured this stuff might be easier to demonstrate directly than to explain, so I went ahead and implemented most of the basic functionality:

https://media.giphy.com/media/2tTKyTu2QI6z3pTKiG/giphy.gif

I’ll PM you the project and that should hopefully make it clear what things you need to change.

The EndEntireFactionTurn function seems to be broken at the moment. I have added it to my list of bugs and will make it a priority to look into. After making this I’m beginning to agree with the complaint from some users that the turn structure is inflexible. I think it is a good candidate for refactoring and I hope I can find the time to do some work on that soon.

As for gracefully jump, do you mean to have the mesh hop from tile to tile as if you were picking up and moving a game token? Could you be a bit more specific?

Ok, glad you figured it out. Have fun breaking stuff :slight_smile:

The 2D example works just as well in 3D. There is not really any difference between the two approaches as far as the toolkit is concerned. The only thing that will be different to implement in 3D is the fog-of war, as the fixed camera angle of the 2D example simply places a flat mesh over the tile. This would obviously not work in 3D and you would have to use 3D fog, procedural meshes, lighting or something else if that is what you’re going for. Could you describe in more detail what you mean with the movement and attacks functioning like a rogue-like? It has become a pretty diverse genre over the years. Are you talking movement using the arrow keys or something else?

Not an official, though there is an unofficial one made by @Flux. Since I have limited time to provide support these days I prefer to answer everything in one go when I have the time, which a forum thread is ideal for. I cannot risk being constantly distracted from my day-job, which giving support through Discord could quickly lead to. However, the Discord is a great place for developers using the toolkit to help each other out, and I might sometimes hop by to chat, but for the reasons described I don’t want to make an official Discord at the moment.

Another reason I prefer providing support in this thread is that the discoverability in the Unreal Engine marketplace is unfortunately abysmal at the moment. Epic are working on implementing tags, but it is still not possible to do simple things like searching for what assets are the most popular. Since I released the toolkit over 3 years ago and the marketplace defaults to sorting everything by date added, having an active support thread that is frequently on the first page of the marketplace forum is the only practical way I have to make new developers aware of its existence.

I think I need some help again. I have tried to add other vehicles but cannot get it to work.

In this tutorial at 10:47 you make a copy of the unit parent to add a static mesh unit to the game.

However, when I try to do the same I cannot seem to find anything like it, I tried making my own by creating a new one based on the BP_Unit blueprint and even got the healthbar to work after copying lots of stuff manually. However, I could not make it selectable or movable. Same when I used BP_Unit_Anim as a base and removed the skeletal mesh and replaced it with a static mesh, seemed to break a few things that I dont know how to fix.

I’m guessing you forgot to delete some of the stuff that calls of the animation blueprint. Try duplicating BP_Unit_Anim again. Delete the skeletal mesh and replace with a static mesh. Then delete everything in the event graph except for the stuff that specifically has to do with the health bar. The event graph should look like this:

https://i.imgur.com/p81gYxT.png

Note that there is also a small bit in the construction script that sets up the reference to the health bar (check BP_Unit_Anim’s construction script)

This works fine on my end:

https://media.giphy.com/media/9Vb9JLAIJyTzVYDFz6/giphy.gif

As for your attempt to use BP_Unit as a base, did you make a child blueprint of BP_Unit or make a duplicate? If you made a duplicate then all the code in the game that references BP_Unit will break for that unit, since it is no longer of the BP_Unit type. Is this what might have gone wrong?