[SUPPORT] Advanced Turn Based Tile Toolkit

Okay, so UE4.20 is out and ATBTT converts fine, with one major exeption. Because of a bug in 4.20 arrays cannot be sent from servers through multicast events to clients. What this means is that replication no longer works for the entire action system (which passes an array of actions to clients), which basically means replication breaks entirely. Thankfully after some trial and error I was able to find a workaround. If you are working on a project using the 4.19 version of 4.20 and want to convert your project, here is how you need to change the event graph of BP_ActionManager:

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

Note that the events are multicast and need to be set to reliable.

I have sent a bug report of this to Epic. As soon as it is up on the bug tracker I will post a link here so people can vote on it if they want it fixed sooner.

This fix is included in the new version I have sent to Epic along with a few of other bug fixes unrelated to the update by Epic (meaning these bugs also exist in the 4.19 version). One is simply that I forgot to turn the health bars in the 2D example visible. The second is that I had forgot to reconnect some nodes in the construction manager of BP_Unit, causing units not to be added to the grid when spawned (apologies to @ for me not realizing this when he asked how to add units to the grid in the new version). The last two were both reported by @JinPengfei in this thread. The first is that multi-level grids did not work properly for rotated grids. The other was that adding tile actor’s edges to the edge array did not work correctly for tiles placed on the edges of levels, causing them to remove connecting edges between the levels. Thanks a lot to @JinPengfei for pointing these ones out. This is a pure bugfix-update, so none of the new features on my Trello have been included here.

I hope anyone reading this thread who encounters any bugs, weird unconnected nodes or typos can report them to me if you see them. The toolkit has become so feature packed now that it is very difficult to properly test for all combinations of things when updating the toolkit, so getting this sort of input is invaluable. As an added incentive, from now on if someone reports a bug I will add a thank you to that developer in the update note above the bug :slight_smile:

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

Same goes for suggestions on how to improve the toolkit that I follow up on (like the improved OwnsUnit macro suggested by @Wisdom- that will be in the next update).

Here is a shorter description of the fixes for the changelist:

v1.83 (19.07.18)

  • Workaround in BP_ActionManager to get around UE4.20 bug of arrays not being passed to clients.
  • Multi-level grids now work for rotated grids. (thanks to @JinPengfei for reporting)
  • Tile actors no longer remove incorrect edges between levels on multi-level grids. (thanks to @JinPengfei for reporting)
  • Health bars no longer hidden in HydrasLair map.

1)Well, i guess that its the case.
Seems to be the culprit.
Any suggestions how we can amend this ? (Also it will be helpful if you can pinpoint us to places it is being set to blank , is it only EndTurn event or other parts as well?)

We really need to access those variables dynamically :slight_smile:

  1. Also we have extra question that is related to making this feature happen :

We need a way to manipulate decals to come out of selected (clicked on) arbitrary tile index without actually moving the unit , or having the unit already on this tile and having to involve changing a turn (end/new turn)
Do you have any suggestion , what is the best way to approach this?

Ok, version 1.83 of the toolkit has been uploaded by Epic to the launcher. This version works with UE4.20. Check my last post for a description of the changes.

I’m not sure I fully understand the question. Do you want to spawn decals when clicking a tile? There is a function for that in BP_GridManager called SpawnTileMarkersAtLocations you can use for this. I don’t understand what you mean regarding having a unit already on a tile and changing the turn. Are you talking about teleporting a unit to a tile and then ending the turn? Could you please explain a bit more in-depth?

Hey ,

currently wondering where the actual unit AI logic takes place?
Is it happening only within abilities? Or where can I see the logic for moving/attacking and so on?

Thanks in advance :slight_smile:

Unreal engine bug report for the issue with using array inputs for multicast events is up on the issue tracker. It seems like Epic is making this a priority and the target fix is for 4.20.1, so that is good. I’d still encourage anyone here to vote on it to decrease the chance of it being backlogged. The issue can be found here.

Hi Robin, the AI logic happens almost solely within the abilities. The only exception is if you’re using the ability system component from the advanced example map, in which case some minor stuff is done to compare the evaluation result from each ability and to generate cached arrays for pathfinding and tile safety estimation which are shared between abilities.

So to see the logic for moving and attacking I would recommend looking at BP_Ability_MoveAttack as well as the parent class BP_Ability. Look particularly at the AiActivate and AssesAbilityValue events.

Well ,thanks a lot we’ve were kinda blindsided and focused on the toolkit structure :slight_smile:
Thanks for your help and support. I will come back if we will encounter any further problems , sorry if i’m not being very clear at describing the problem , the way we want to make toolkit work is pretty different from its default state so its hard to give you enough information without confusing you:)

Epic received and resolved the issue I reported on the same day! In the words of Civ V’s science advisor: Now that’s efficiency!

https://i.imgur.com/44YziWH.png

Hope my comments still point you in the right direction, even if I didn’t understand your issues completely :slight_smile:

Hey ,

I also took a look at x-com style movement display a few weeks ago but the tangents made my head hurt. So instead i decided an outline post process would be the easier option, like this.

But if you have it working with splines it will be interesting to see how it works.

Thanks for the input, elec2ron. I’ve also looked into using render custom depth to make an outline. However, the issue then becomes to shape the mesh that the post processing will create an outline of. The underlying meshes would still have to conform appropriately to the terrain if the outline is to look good. Have you thought of a way to do this or to get around the issue?

Yes i am creating procedural meshes for the display tiles now, i trace points to get the correct positions for the mesh verts so it can conform to any environment. We found this to be the best solution for us as while the tile decals looked great on landscape they ended up looking quite nasty on lots of our mesh floor tiles.

Yeah that makes sense. I was planning to look into procedural meshes at some point for this purpose. Are you using multi-level grids, or just single-level grids with height maps? I imagine the former would be a lot more challenging.

For multi-level grids i use the Height Between Levels var for the trace start height, then to make sure i do a multi trace and use the hit closest to the relevant tile index. Also have a new trace channel just for walk-able floors so nothing else gets in the way.

I think I misunderstood you slightly. This might stem from my lack of experience when it comes to using procedural meshes. Are you using a single, large procedural mesh for all the tile markers or are you using one individually for each tile? If you’re doing it individually then I can see how you can run traces on each corner of the tiles and have them line up with the neighboring tile. But if you’re doing something where you merge all the meshes together into one large procedural mesh then I imagine finding the correct adjacent meshes would be challenging; particularly for multi-level grids. Would you mind sharing a screenshot so I can understand it better?

Here is a simplified example.
I create a single procedural mesh component then add a mesh section for each tile. First you create the verts from the tile x/y and the z from the trace. Then you create the triangles and uv’s from the vert array indexes.

This is an example of 4 verts but i have found that 9 is enough to conform to terrain nicely.

It would be more complicated to create all the tiles from one mesh section but it would result in less draw calls so is perhaps worth it. To simplify it i would add 4 new verts to the array each loop as there is no real need to have each tile welded to the adjacent ones.

@elec2ron : Thanks a lot for the explanation! Using procedural meshes for something like this is something I’ve had in the back of my mind for a long time, but as I assumed it was going to be a lot of work to implement I’ve kept it low on the list. Thanks to your input I might try my hand at this a lot sooner. Not this update, but maybe the one after.

Trying to use this grid code in multiple projects, one of them being a tower defense so that in game I can only place on the grid. I see that BP_unit automatically snaps to grid while in view port editing and obviously in game. Does anyone know where the code for this is so i can replace BP_Unit with my Tower parent?

You can find similar code for grid snapping in the construction scripts of BP_GridActor and BP_Unit. I recommend looking at BP_GridActor unless you are using the character class for your towers. The relevant blueprints are near the end of the construction script’s execution chain. There is no way I know of to get grid snapping working for the scene root of the actor so I found a workaround. I add another scene component that I call GridAnchor to which I attach everythin I want to snap to the grid. Then I place the GridAnchor at the center of the closest tile when moving the actor in the construction script. If I later want to get both of these scene components aligned and have the actor itself be at the center of the tile I place the actor at the location of the GridAnchor and then set the grid actor’s location to the location of the scene root.

Hi There I’m having a small trouble getting units to spawn and act correctly on the Grid. I’m trying to integrate the Dungeon Architect with the toolkit. I’ve been able to sync the grid manager and dungeon generator but when I try to spawn the units they are unable to move.

I’m able to spawn randomly on the grid using the Advanced game mode and the following level blueprint. As you can see the unit spawns and snaps to the grid, but the HUD and logic don’t seem to start. I’m using the Dungeon Architect to pick a random tile which should sync up with the Grid Manager.

Love how my placeholder meshes look in Dungeon Architect :wink: I’m guessing you do not have any units placed beforehand when the game starts? If so the game does not start automatically and you have to call the StartMatch event in BP_TurnManager manually after spawning units. See if that works.

The assets work surprisingly well! You’re correct I’m spawning them from the level blueprint at runtime.I’ve access the BP_Turnmanager using -> Cast to Turn Manager class -> get all actors of class -> Start match.

However the unit can only move to certain tiles, others are blocked off. I’m using Multi height grids. I did have to offset the gridmanager by X 100, Y100. Could this be the issue?