# \[SUPPORT\] Advanced Turn Based Tile Toolkit

**URL:** <https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930>\
**Category:** UE Marketplace\
**Tags:** unreal-engine, fab\
**Created:** [February 26, 2015, 8:30am UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930 "2015-02-26T08:30:16Z")\
**Posts on this page:** 20\
**Page:** 46

<div class="post-metadata">

**Author:** ![Monokkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monokkel/32/1194496_2.png) [@Monokkel](https://forums.unrealengine.com/u/Monokkel)\
**Post date:** [June 19, 2016, 4:08pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/943 "2016-06-19T16:08:06Z")

</div>

I try my best 🙂 Let me know if you have any questions.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9433d2ac](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9433d2ac](https://forums.unrealengine.com/u/anonymous_user_9433d2ac)\
**Post date:** [June 19, 2016, 6:13pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/944 "2016-06-19T18:13:01Z")

</div>

> [@;531782](#):
>
> Happy to help 🙂
> 
> I got a question by a user by e-mail that I think other users might also be wondering, so I’m posting my answer here. He was wondering whether it was possible to make it so that diagonal movement is 50% more costly than straight movement on a square grid. Here is my answer:
> 
> The easiest way to do this is to make the cost of straight movement 2 and the cost of diagonal movement 3 and then doubling the movement attributes of all units. Here is how you can add this in the Generate Gameplay Grids function in BP\_GridManager:
> 
> ![M2mP1IG.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/0/2/202592b6803d7abd2069a86c21450f881bed140a.png)

Hello,

I tried this tip for increasing the cost of diagonal movement by 50% and it work perfectly but only on the first level of the grid. The units move now twice further on the higher levels. How can I adapt this for a multi-level grid ?

Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![Monokkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monokkel/32/1194496_2.png) [@Monokkel](https://forums.unrealengine.com/u/Monokkel)\
**Post date:** [June 20, 2016, 8:57am UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/945 "2016-06-20T08:57:10Z")

</div>

Totally forgot about how edge costs are set separately for higher levels. These costs are set in the Add Viewport Terrain To Arrays function in BP\_GridManager. Generally what you need to do is to double the cost each time a cost is set within that function. I will not be home until tomorrow so I cannot show you exactly what you need to change at the moment. If you do not manage to achieve the desired result by doubling all cost variables in Add Viewport Terrain To Arrays by tomorrow I will show you using screenshots.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9433d2ac](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9433d2ac](https://forums.unrealengine.com/u/anonymous_user_9433d2ac)\
**Post date:** [June 20, 2016, 3:44pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/946 "2016-06-20T15:44:22Z")

</div>

Yes I figured it should be on the “add viewport terrain to arrays” but didn’t saw a reference to the cost (I checked your blueprint video on youtube but there is a lot of changes since this vid). I’ll have a second look, I’m new in UE4 and sometime, BP can be a little bit mazy.

Thanks for the help 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9433d2ac](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9433d2ac](https://forums.unrealengine.com/u/anonymous_user_9433d2ac)\
**Post date:** [June 21, 2016, 1:07pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/947 "2016-06-21T13:07:48Z")

</div>

> [@;551089](#):
>
> Totally forgot about how edge costs are set separately for higher levels. These costs are set in the Add Viewport Terrain To Arrays function in BP\_GridManager. Generally what you need to do is to double the cost each time a cost is set within that function. I will not be home until tomorrow so I cannot show you exactly what you need to change at the moment. If you do not manage to achieve the desired result by doubling all cost variables in Add Viewport Terrain To Arrays by tomorrow I will show you using screenshots.

I tried yesterday to find were to set the costs in the function but was not able to achieve it. Your screenshots could be a big help for me 🙂

---

<div class="post-metadata">

**Author:** ![Monokkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monokkel/32/1194496_2.png) [@Monokkel](https://forums.unrealengine.com/u/Monokkel)\
**Post date:** [June 21, 2016, 2:03pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/948 "2016-06-21T14:03:26Z")

</div>

Hi again, I have access to my computer now. Little wonder you had trouble figuring this out yourself, as it was quite a bit more complicated than anticipated. In the Gameplay Grids function it is very straightforward to identify which edges are diagonal and which are straight, but at a later point this is more tricky, as the Edge Array does not distinguish between various forms of edges. There are many ways to determine this, however, so it is definately doable, but takes a bit more work than just doubling the edge costs set in the graphs. You just need to alter one macro, though, which is the _Get Edge Cost from Z difference_ macro. Here is how to alter it so that it sets the edge costs of all straight edges to 2 and all diagonal edges to 3:

 ![LfMQCZj.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/7/1/719027b935e4ef53410c5eadef00febc79b45f22.png)

Here is the original for comparison:

 ![618d90c023c6bfd45068aa12d0dc0228f8e21dc6.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/6/1/618d90c023c6bfd45068aa12d0dc0228f8e21dc6.png)

Since this modification alters the inputs of the macro you will also need to connect the index of the parent tile instead of the Z height of the parent tile every place the macro is used. It is used three times in Add Viewport Terrain To Arrays. You can easily find all three by right clicking the macro in the MyBlueprint tile and selecting Find References.

This seems to do the trick. Hope that helps!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9433d2ac](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9433d2ac](https://forums.unrealengine.com/u/anonymous_user_9433d2ac)\
**Post date:** [June 21, 2016, 5:39pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/949 "2016-06-21T17:39:00Z")

</div>

Thank a lot ! I’ll try this as soon as I can 😃

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9433d2ac](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9433d2ac](https://forums.unrealengine.com/u/anonymous_user_9433d2ac)\
**Post date:** [June 21, 2016, 8:39pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/950 "2016-06-21T20:39:25Z")

</div>

It work perfecly, thanks a lot man, you’re da man 🙂

One last thing : Do I need to also change something in the “tile parent” BP (in the “make edge cost int array” function?) ? I double the edge costs of the “tile\_cost 2” (from 2 to 4) but it doesn’t seems to do the trick anymore.

In any case, thanks a lot for your quick answers 🙂

---

<div class="post-metadata">

**Author:** ![Monokkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monokkel/32/1194496_2.png) [@Monokkel](https://forums.unrealengine.com/u/Monokkel)\
**Post date:** [June 23, 2016, 7:58am UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/951 "2016-06-23T07:58:50Z")

</div>

You should not have to change something in the functions. Doubling the edge costs does seem to do the trick on my end (though you should multiply diagonal edge costs by 3). Like this:

 ![dIB7kIq.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/e/7/9e7189f78bd356b612213388ad9e10ef2d9681d7.png)

For this result:

 ![krFuUdG.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/a/2a781bf8e458ba526958807d66abf5f6a39fa771.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9433d2ac](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9433d2ac](https://forums.unrealengine.com/u/anonymous_user_9433d2ac)\
**Post date:** [June 23, 2016, 8:37am UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/952 "2016-06-23T08:37:04Z")

</div>

That’s really strange, on my hand tiles with cost doesn’t work anymore.

And it also seems to have an impact on the multilevel : If I don’t have a Tile with cost on the edge of my higher level, pawns can just ignore hight and walk from a level to an other.

 ![cost2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/4/6/46b003282b159e6ef4d74b64dc0583888b76931f.jpeg)

---

<div class="post-metadata">

**Author:** ![Monokkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monokkel/32/1194496_2.png) [@Monokkel](https://forums.unrealengine.com/u/Monokkel)\
**Post date:** [June 24, 2016, 1:17pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/953 "2016-06-24T13:17:49Z")

</div>

That is very strange. It works fine on my end. Can you post screenshots of all three locations of Get Edge Cost from Z difference in Add Viewport Terrain To Arrays so I can see if everything is hooked up correctly?

---

<div class="post-metadata">

**Author:** ![charliepilotti](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@charliepilotti](https://forums.unrealengine.com/u/charliepilotti)\
**Post date:** [June 28, 2016, 2:54pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/954 "2016-06-28T14:54:01Z")

</div>

is there a tutorial on the 2d hydra’s lair map? I tried to recreate it using my own tile sheet and the character doesn’t move!

---

<div class="post-metadata">

**Author:** ![Monokkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monokkel/32/1194496_2.png) [@Monokkel](https://forums.unrealengine.com/u/Monokkel)\
**Post date:** [June 28, 2016, 7:35pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/955 "2016-06-28T19:35:17Z")

</div>

Hello charliepilotti, I plan to make such a tutorial in the future, but have not gotten around to it just yet. There might be many reasons why the character doesn’t move. Could you explain all that you have done so far? Is it just the grid manager placed on top of a tile sheet? The first thing I would check is to see if your tiles have collision enabled and are set to block PathTrace. If that does not work, please explain what you have done in a bit more detail and I will try to find the problem.

---

<div class="post-metadata">

**Author:** ![charliepilotti](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@charliepilotti](https://forums.unrealengine.com/u/charliepilotti)\
**Post date:** [June 30, 2016, 11:19pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/956 "2016-06-30T23:19:04Z")

</div>

hey man I actually got it working, I hard to restart my editor. Even though I added the path trace to collision it wasn’t showing up until I restarted. Another thing I actually had a question about is what use is the dungeom tilemap base? I can’t see where it’s actually being used, but i’m still new to visual scripting.

---

<div class="post-metadata">

**Author:** ![Monokkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monokkel/32/1194496_2.png) [@Monokkel](https://forums.unrealengine.com/u/Monokkel)\
**Post date:** [July 1, 2016, 8:39am UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/957 "2016-07-01T08:39:09Z")

</div>

Good that you managed to get it working, though it is weird that it required restarting the editor. I’m not at home and cannot currently check the toolkit, but I believe there are three different tilemaps: one containing all walls, one containing all floors and one containing both. I think the third one is tilemap base. In any case, the one containing everything is the one I used to make the entire dungeon, so I knew how it would look with both walls and floor tiles in place. I then made two duplicates: one where I removed all the walls and one where I removed all floor tiles. Then I made the one with just the floor tiles block path trace and the one with only walls to have thicker collision boxes (pointing up towards the camera) and block range trace, so that walls would block visibility. I kept the base tile map in case I needed to go back to it for any reason, but it does not serve any real purpose in the finished toolkit.

---

<div class="post-metadata">

**Author:** ![stormhierta](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@stormhierta](https://forums.unrealengine.com/u/stormhierta)\
**Post date:** [July 4, 2016, 11:47am UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/958 "2016-07-04T11:47:29Z")

</div>

Hi!

A little curious when the next update is coming? We’re especially interested in the cover/accuracy system.

---

<div class="post-metadata">

**Author:** ![Monokkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monokkel/32/1194496_2.png) [@Monokkel](https://forums.unrealengine.com/u/Monokkel)\
**Post date:** [July 4, 2016, 8:42pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/959 "2016-07-04T20:42:33Z")

</div>

Hi there! It’s going forward, but a bit slowly. Work has been busy, and in addition I’m getting married in a week and then going on an extended honeymoon, so I’ll be pretty occupied for the next few weeks. I have however implemented both a cover and accuracy system that is probably pretty close to what I’ll end up including in the update. I’ll explain my solution in this post so that anyone who needs a cover system quickly can replicate what I’ve done.

First to create some context for the blueprints below, I’m creating a new example map to include features like cover and accuracy. Since I do not consider these features generic enough to include in the base toolkit (to avid it from getting cluttered) I’ve added these features in child actors of the original actors. The example map has the working title SciFi because of some SciFi themed assets I’m using, so the child actors are called for instance BP\_GridManager\_SciFi and ATBTT\_PlayerController\_SciFi. In the blueprints below I will frequently be casting to these child actors to get access to their functions and variables, though if you want to replicate this yourself you might not want to use child actors and could just modify the base actors themselves.

The goal of my solution for cover is to have everything be pregenerated based on the terrain placed in the level, both to save time for the users and to speed up processing during gameplay.

For cover I have created a new array called Cover Array in BP\_GridManager (or really BP\_GridManager\_SciFi). This array is a nested array of structs. It is an array of arrays, where each nested array is an array of structs containing an index integer and a cover float. The main array is resized to be the size of the grid. The idea is to have each index of the array represent a tile on the grid and each member within the nested array represent a tile edge of each tile, pointing to which index the edge is facing and what its cover value is (hope that’s clear 😛 ).

To auto generate cover at the start of the game I have created a new trace channel I call Cover Trace. I then trace between all tiles two times using this trace, one quite low and one quite high. If the high trace is blocked I count this as full cover between tiles (with a high cover value). If the high trace is not blocked, but the low one is I count it as half cover.

 ![73iRzEY.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/0/e04dadf46e51040a4e5907d3f3973188612a9fc2.png)  
 ![fBWy5BS.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/3/7/373289749ef290c3f94b5721a451f1be66717ac8.png)

I’ve made the following function to check whether a tile has cover from another tile. If the attacking tile is on the other side of the cover edge, accuracy is always reduced by the same amount, regardless of how far to the side of the cover the attacker is standing. This is both easier to calculate and probably for a player to understand.

 ![WS8txzW.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/2/1/21f75fca40f1b79119d7041594e775a6fd453a4d.png)

For calculating hit chance I want to take into account more factors than just cover, so I have made the following function to take distance and other modifiers into account:

 ![73iRzEY.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/f/7/5f74f546f3d5f9cc46fc0425e0b8b198903657d4.png)

All functions so far have been contained in BP\_GridManager\_SciFi. I have also created a new unit child actor currently called Unit\_Player\_SciFi\_Weapon (so called because I’m experimenting with units carrying weapons that can be switched). This unit has new attributes called Accuracy and Dodge. Accuracy is a value between 0 and 1 representing the base percentage chance this unit has to hit another unit with its attack. Dodge is a similar number subtracted from the accuracy of any unit trying to hit _it_. Here are the nodes I use in the event graph of this unit. These nodes are inserted as part of the Attack Victim event, before Attack Animation, but after all other nodes.

 ![fBWy5BS.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/2/4/724a592c5e57234c959e6cc3524a4feee46d6157.png)

It is still a work in progress and I have also added more functions for displaying XCOM-style shields for cover and such. What I have described above should still hopefully be enough to get you started. I hope I have explained it well enough, but feel free to ask if you have any questions. Like I said I will probably not have any time to work on this until I return from my honeymoon in August.

---

<div class="post-metadata">

**Author:** ![kevdotward](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kevdotward](https://forums.unrealengine.com/u/kevdotward)\
**Post date:** [July 6, 2016, 12:41pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/960 "2016-07-06T12:41:11Z")

</div>

> [@;559192](#):
>
> For cover I have created a new array called Cover Array in BP\_GridManager (or really BP\_GridManager\_SciFi). This array is a nested array of structs. It is an array of arrays, where each nested array is an array of structs containing an index integer and a cover float. The main array is resized to be the size of the grid. The idea is to have each index of the array represent a tile on the grid and each member within the nested array represent a tile edge of each tile, pointing to which index the edge is facing and what its cover value is (hope that’s clear 😛 ).

I had to read that several times… 🙂

Like many following your progress, I’m greatly interested in the cover system. The way you’re setting it up has cover precalculated, is it possible to then run the cover traces in game? I’m thinking about when weapons fire or explosives destroy cover during the game, requiring a recalculation of what cover covers what pawns. I assume that if the traces are run during the game there would be a bit of a performance hit on large grids to run so many line traces so you don’t want to do it every time a weapon is fired?

I seem to remember actually that there was a bit of slowdown in XCom whenever cover got destroyed. Could be that they used something similar to your system.

And congratulations on the wedding and honeymoon !

---

<div class="post-metadata">

**Author:** ![Monokkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/monokkel/32/1194496_2.png) [@Monokkel](https://forums.unrealengine.com/u/Monokkel)\
**Post date:** [July 6, 2016, 1:03pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/961 "2016-07-06T13:03:03Z")

</div>

Thanks! Yeah, it was a bit tricky to explain 😛 Maybe I can make it a bit clearer. Below are four array elements (of which there would be a number equal to the size of the grid). Each of these contains a nested array (of four elements each in this example, though this would vary depending on the number of edges of each tile). Each of these array elements contain an integer and a float. The integer points to an adjacent tile (the edge being between this tile index and the tile index of the array element in the main “parent” array) and the float defines the cover value of this edge.

\*\*\*\*[int,float] [int,float] [int,float] [int,float]**] \*\* \*\*\*\*[int,float] [int,float] [int,float] [int,float]**] \*\* \*\*\*\*[int,float] [int,float] [int,float] [int,float]**] \*\* \*\*\*\*[int,float] [int,float] [int,float] [int,float]**] \*\*

It should be possible to re-run calculating cover for a smaller area. Just use the Get Indexes In Range function in the area where cover may have been destroyed and then run the same cover generation code for these tiles as was originally done for the entire map. I designed the cover system with this possibility in mind, and though I have not tested it out yet, I see no reason why it should not work.

---

<div class="post-metadata">

**Author:** ![kevdotward](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kevdotward](https://forums.unrealengine.com/u/kevdotward)\
**Post date:** [July 6, 2016, 2:44pm UTC](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930/962 "2016-07-06T14:44:50Z")

</div>

I think I did actually misunderstand a little originally, thanks for this explanation. Yes the way you have it here running the cover trace in game in a given area should be reasonably efficient - I was anticipating that the whole level would have to have the traces re-run at once but that’s not the case.

One further question (if you have time) - how does this work with multi-level grids or altitude differences?

[Previous page](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930.md?page=45)

[Next page](https://forums.unrealengine.com/t/support-advanced-turn-based-tile-toolkit/21930.md?page=47)
