[SUPPORT] Advanced Turn Based Tile Toolkit

@Rob3342421: Glad you figured it out! The way I suggested it each unit can have its own accuracy and dodge, as I feel is most common in games. Values should be between 0-1 representing chance of hitting and chance of dodging a hit respectively. Thanks for noting my spelling mistake. I’m sure there are many more in the toolkit, though.

@Gugenheimer: I have used a separate pawn myself. I would suggest following Epic’s tutorial on their wiki (which is what I did) here. I used the official vive motion controller meshes which can be found in SteamApps/common/OpenVR/resources/rendermodels/

Below is my solution for touch controls at present. Note that this is something I have quickly hacked together and it is unlikely that it will look like this in the next update. It does seem to work well, however. The general idea is to send a line trace from the motion controller and have the toolkit count any tile hit by the trace as if the tile was hovered over or clicked by the mouse.

In my VR pawn I run a line trace in the PathTrace channel every tick with a debug draw as a sort of laser pointer. If it hits something blocking PathTrace I run it through Vector to Index 3D to find the corresponding tile index and feed it to my custom Vive Hover event in ATBTT_PlayerController. Pressing the trigger does something similar, though it does not draw a debug line and instead fires the Vive Touch event. In the future I will probably want to check if BP_GridManager is actually hit before running the Vector to Index function as I do not want to run such a function every tick if it is not necessary.

The additions to ATBTT_PlayerController are very simple and are as follows:

They are located at the end of the Mouse Input comment bubble and at the top left part of the Display path on hover comment bubble respectively.

That’s pretty much all there is too it for getting the basics working. There is lots of tweaking to be done, of course, but this is enough to get your virtual board game to come to life. I hope you find implementation easy and I’m looking forward to seeing what you make!

Thanks for the tips! I won’t be able to get back into my project until this weekend but can’t wait to get this implemented.

Your toolkit is amazing! One question - is it possible to make free unit selection instead of initiative-based, via next faction turn selection after previous faction ends its turn, for example? Thanks!

@Gugenheimer: Best of luck!

@Waldesfray: I’m not sure if I understand you correctly, so correct me if I’m wrong. Units can already be selected freely if the Can Player Switch Pawns public boolean in BP_GridManager is set to true. You can also split initiative into factions by making sure that all factions have initiative values in ranges that do not overlap. But maybe you mean that you want to want to prevent the toolkit from automatically selecting a new unit when a unit has ended its turn? This can be changed by removing the Activate Unit call from the End Unit Turn part of ATBTT_PlayerController. The only problem with this is that your turn will not end even if all your units have acted so you need to add a few nodes. Here is my solution to that problem:

Thank you very much! This solution partially solves my problem :slight_smile:
I tried to adapt the game for situation, when the players act against AI, and generate common strategy each turn, so the main idea is to let hot-seat players choose the next acting player (faction) manually (via GUI) inside each phase of combat, as if their initiative was equal.

I got my rendering issues squared away. I can see the laser pointer from the vive controller however the pawn’s path only goes to where the camera looks.

I was going through tutorial 6, Adding New Features and when I add destructible trees, they fall through the floor when I blow them up. Any ideas what causes it? Perhaps Unreal added a new setting.

Edit:
I think I’ve figured it out. When Default Tile Object is set to Instanced Static Mesh, the destructible mesh falls through the terrain, Static Mesh works fine.

One more question about the tutorial 6 video. At 33 mins 54 secs, you do a Split Struct Pin command on the Set Array Elem function, which gives you Item North, Item East, Item South, etc.

When I do it I get Item Edge Array Tile, so I don’t know what to do next.

@Gugenheimer: Odd. Where the camera is looking should not make any difference. Maybe I’ve forgotten one small detail when giving you the solution. Try troubleshooting the issue by using Print Stings along the chain of nodes. Check if the custom event is actually being fired when you click the trigger, check what the location of the trace hit is etc. This is the way I do it myself when trying to find what is wrong. It is probably some very small thing since you’ve got most of it working.

@Ariegos: Some of my tutorial videos are a bit outdated because of the new update. This is one of the videos where this is particularly apparent as I have changed how the edge array works. Before each tile always had eight edges (north, north east etc.) that had values of 0 if they were not passable. In the new update tiles do not have any edges with a value of 0, so the amount of edges can vary from tile to tile. Modifying these new arrays can be a bit tricky, partially due to some limitations to how nested arrays work in blueprints. Because of this I’ve created some functions that should make things a lot easier. They can be found under the Utility tag in BP_GridManager. The functions for manipulating the edge array are as follows:
**
Remove Tile Edge**: Takes as input the indexes of the tile you want to remove an edge from and the tile you want to remove the edge to. So for instance if tile index 4 has the edges connecting it to tile 3, 5 and 8 you can input Tile Index 4 and Edge 8 to remove the edge between index 4 and 8. This means that you can no longer move from index 4 to 8. Note that if tile 8 has an edge connecting it to tile 4 you can still move in that direction. To remove edges both ways you would use Remove Tile Edge Both Ways.

Set Edge Cost takes a tile index and an edge as input just like Remove Tile Edge, but instead of removing it you change the cost of passing to the target tile through this edge. This can be set using the New Cost input.

Add Edge adds a new edge where none was before with a cost of your choice. Inputs are the same as for Set Edge Cost. Like Remove Tile Edge, Add Edge also only works in one direction, so to add edfes both ways you would use the Add Edge Both Ways function. Note that because of some limitations to how I was able to design the edge array you cannot use these functions to add an edge to a tile that has no edges at all. If you want to make a tile that is completely impassable connected to the rest of the grid you will need to use:

Make Tile Passable: This function connects an index to all surrounding tiles that are not themselves impassable with edge costs of 1. This is a useful function for the tutorial where you want to make the tile that was previously impassable and occupied by a tree to be passable. You can easily do the reverse by using the Make Tile Impassable function.

I hope this explanation makes sense, and I apologize that my tutorial is a bit outdated. I intend to make a new tutorial video in the future that explains how the edge array works among other things. For now I will add a link in the description of the tutorial video to this post.

Thanks for the detailed answer. Make Tile Passable works great.

Happy to help :slight_smile:

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:

, I believe my issue is I have not set up the grid manager Ref in my pawn correctly. The message I get is " Accessed None trying to read property Grid Manager Ref", same for the player controller ref.

If your units are parented to Unit_Parent and you have not modified Unit_Parent itself they should stil access the correct references. Have you perhaps overridden the construction script or Event Begin Play where references are normally set up?

First of all, Great toolkit.
This is helping me alot with my time travelling RTS project.
I do have a few brief questions however to see what the more optimal way of doing this is.

First off my levels occur across multiple eras from prehistoric to the future (land unit and vehicle rts combat).
I want to limit my units to certain eras only but have both factions using them. (ie populate 4 units for my player and then spawn the exact same units for the NPC player with a different colour skin) Do i need to create each unit twice (faction blueprintper unit) for this to work in the toolset or is there a function i could call so that both factions would use a single character blueprint to call the functions.

Not sure if this has already been answered and if it has, I’m sorry.

I am trying to make text that will rotate with the camera so that the text is facing the camera at all times.

A friend has shown me one way of doing it however I don’t think it works with the spring arm or isometric camera. This is what I have so far:

So currently I have a blueprint with a text renderer in the viewport saying what I want it to. Then in the event graph is what you can see in the image. While it is rotating it looks a little strange, I was hoping you could help me make it work with the spring arm. I’ll continue to try and fix it and if I find a fix then I’ll post a reply myself.

cheers

@Nightraiyven: So you are making a real time game with my turn based toolkit? It is not really what it is designed for, but I hope you can find it useful nonetheless. As for your question you can use the same unit for both the player and the AI. Just make sure to set their faction, AI Controlled and Allied Factions to the appropriate values when you spawn the units.

@Rob3342421: You are on the right track. However with the nodes you have posted above the actor will face the location of the player pawn, which may or may not correspond to the location of the camera (in the case of they will never be the same). Therefore you need to cast to BP_GridCamera, get a reference to the camera on that actor and use its location. Since casting is expensive it is best to not do it every tick, so in the nodes below I cast and set up a reference at the Event Begin Play:

Hopefully that should do the trick :slight_smile:

Does your toolkit support units that take up more than one tile?

Not at present, no. If I add it in the future it will be in an example map and not as a general feature of the entire toolkit. The thing is that adding multi-tile units is not terribly difficult in itself, but it becomes increasingly complicated depending on how many other features I need it to work together with.

For instance, adding one new type of unit that is 2*2 tiles on a square grid that can only be controlled by the AI is the simplest take. If I want it as a generic feature I would want to add multi-tile units of arbitrary size for both hexagonal and square grids that work on multi-level grids and can be controlled by the player in a way that makes sense in how tiles in move range are displayed for units of any size. I have experimented with this quite a lot, and any solution I can think of that solves all of these problems becomes extremely convoluted and inefficient. It is a lot better to tailor the solution to whatever game is being made, which is why I will add it as a feature of an example map when I add it.

Hi, thanks for the quick reply and this has done something however the text is not correctly displayed. I’ve tried inverting the results to get the text to show the correct way but I cannot get it right. I’m not sure if its something I’ve done or if its just not working right, this is what I have:


And this is what it does, the text seems to rotate the wrong way:

I’m not sure whether an axis needs to be ignored or if the results need to be inverted but its strange.

Seems like you are getting the capsule from instead of the camera. Try getting the camera instead and see if that works.