[SUPPORT] Advanced Turn Based Tile Toolkit

Hi, Knutt,
Firslty, seems like a super cool pack you’ve created and a good proper support thread :slight_smile:
Okay, super newbie question here.
I just started out with this and are following your tutorial “UE4 - ATBTT - The Action System - 3/3”
Everything works as expected up till 15 min, the animation part or the teleporting just isn’t happening, not even the one where the unit is clipping with the tile.

From my own debugging I’d guess it’s somewhat related to Queue Action, since if the Queue Type is set to “Immediate”, the pawn actually does teleport, but before starting to move.
I’ve now spent +3 hours on a 15 min tutorial and are feeling really stupid, is there any chance you could help me out and tell me what’s up?

Hey ,

So i change the damage variable and made a another copy just to make sure it wasn’t the blueprint itself and even though damage is calculating the enemy is still there. Does this have to do with the grid reference?

Hi I’m having trouble spawning units at runtime.
I’ve searched through the support thread and tried implementing the different fixes but I’ve had no luck so far.

I have an ability that uses Spawn Actor to create a Adv_Heavy unit at the correct grid tile, the constructor seems to work and it gets placed in the turn order / initiative. When it comes around to their turn the Unit doesn’t have any abilities and cannot move or act. I’ve checked the starting abilities and it has Sprint, Laser, Grenade etc in the array. I am also unable to end the turn once it becomes their turn.

Also I noticed that Status Effects can have run at turn end / start, is there anyway of having them activate on the start / end of a units turn, not at faction turn?

Thanks in advance.

Terribly sorry for the late reply, everyone. Had some sudden things in my life that took precedent, but it is back to normal now.

Hi Anton, I cannot immediately see what is wrong here. I will have to test it out myself and see. Will try to do so tonight. I have made some changes to parts of the action system since that video, so it might not be you who are doing something wrong, but rather a difference between versions.

Could be the reference to the unit which is returning false. You can test this by dragging an isValid node out from the unit and printing it at each point where it is accesed and see if it ever returns false during play. That should help to narrow it down. Were my previous explanations for how and when units are removed from the grid clear to you?

Hey SSL_Dev, seems like spawning advanced units at runtime has become a bit more involved following a refactoring. Seems I forgot to test this. I will try to find a solution tonight. The first step should be calling SetupUnitAfterAssignedOwner in the HandleUnitSpawning function in BP_Unit. This works as long as the unit only has abilities that already exist on units that were placed in the viewport beforehand.

Ok, I’ve looked into this in depth now. This is caused as a consequent of my refactoring, so you did everything correctly. It is the tutorial that is outdated. The reason for what you’re seeing is that the Move action is now queued after SimulateMove, while before it was queued before. As a result, if you queue the teleport action during simulate move it will be animated first, followed by the animated movement. If you have not completed the entire tutorial and added explosions, delays etc. it will seemingly not happen at all, since the unit is moved during a single tick and then immediately moved back to where it is at the start of the move animation (which is the next queued action).

So in newer versions you will have to do things a bit differently. I have since added more options to the QueueAction macro. Instead of a boolean checkbox for immediate or not, you can now select Queued, Immediate or Interrupt. The first two are the same as with immediate checked and unchecked before. The third one enables you to add a new action to an ongoing queue that is currently being animated. This can be utilized in the teleportation example.

You can use the following code in BP_Teleporter to achieve the same effect as the tutorial using an action set to interrupt. In this teleporter we bind a new event. This time to the animate version of the dispatcher run at the end of a unit’s movement. Then, when the unit has actually moved to the teleporter during animation we queue a teleport action set to interrupt, which should animate immediately after the move animation is done.

You can see a similar setup in the spike traps in Maps/Experimental/InterruptAction. If you have a game where you expect a lot of interrupted actions I recommend looking at the SplitAnimations map in the same folder, which includes a unit that splits its movement into multiple actions, making it much easier to insert actions when units enter particular tiles. The example map includes a teleporter and a ladder.

Hey, I’ve looked into this now. Seems like a combination of two issues. The first is that SetupUnitAfterAssignedOwner needs to be called during HandleUnitSpawning, like so:


The second issue is a bit more tricky, though. The issue is that UnrealEngine requires a delay of one tick (possibly more in multiplayer) to access a freshly spawned actor. This causes issues where the toolkit spawns new abilities during runtime, but fails to add them to the appropriate arrays, since the references do not yet exist. This makes spawning units during runtime for units with fresh, unused ability classes not work properly. I will try to find a proper fix for this in the next update. Until then, here is a hack that works well:

In BP_PlayerController_ATBTT create an array of BP_AbilityBase classes. In its default values include all abilities that can possibly be used in your game. At BeginPlay for the player controller loop through this array and call GetAbilityOrAddIfMissing for each of them. This will make all these abilities available when newly spawned units are looking for them:

Thanks that worked perfectly!

Is there a place that a unit / tile can store how many turns its been alive? I’ve had a look and I can’t seem to find anything. I’d like to be able to destroy units / runtime added tiles after a set number of turns. I’ve made a status condition that works for Units but not for tiles. Also a I mentioned previously this Activate on turn start seems to be the faction turn start, is there a way that it can run on the individual units turn start?

thanks in advance

Hi ,

Thank you for that explanation it was very clear and through some more testing I’m now trying to figure out where to properly place these IsValid nodes as I’ve place them at the points in the ability itself when its calling for a grid unit reference.

Sure, there are a number of ways you can keep track of how many turns a unit or tile has been alive. The most straightforward way is to add a new integer to each to keep track. Then you could add a new event dispatcher in BP_TurnManager that you call after the BeginNewTurn event. You could bind events that increment the turn counter in the BeginPlay events of each relevant actor.

When it comes to activating the unit on the start of the unit’s turn versus the entire faction’s turn look into the different turn managers BP_TurnManager and BP_TurnManager_Initiative. The first one is the default and splits initiative into factions, activating status effects etc. for all units of a faction at the start of that faction’s turn. BP_TurnManager_Initiative instead has a D&D style initiative order, where turn start effects are run at the start of each unit’s turn. Compare these two blueprints and see if it makes sense to you. You can change the turn manager used by changing TurnManagerClass in BP_ATBTT.

Ok, great. Hope that helps you figure out the problem. If not, the info you get from this should help me figure out what might be wrong.

How would I set up tile-based movement even when out of combat?

I’m envisioning free roaming movement like Solasta: Crown of The Magister where the player can control x number of characters and move them in formation on a grid - I’m sure I can figure out the formation logic once I’ve got 1 character moving correctly https://youtu.be/f1uUDj1JIsg

Also is there a certain workflow you should have when setting up maps for use with the grid? I imagine it’s difficult to take for example a marketplace asset level and use it with a procedurally generated grid - should you instead set up the grid and manually place actors and such to build out the level?

You could use the top down example project by Epic as a base. What you would change is that when you click a location to move to, you would convert the world location to a grid index using the ConvertLocationToIndex3D function in BP_GridManager. Then use this index to get the tile location through the GridLocations TMap in BP_GridManager and make this the destination of the top down movement. For later converting from real time to turn based movement after combat starts take a look at the Hybrid example map in Maps/Example/Hybrid.

The toolkit procedurally generates grid locations and walkability. However, if you use a premade map you will likely need to do some moderate adjustments. Firstly, you should make sure the map conforms to a grid of the size you are using (200*200UU is default for the toolkit, but can be changed). If not you can get strange results like a tile where the center is on the very edge of a cliff, with half the tile hanging over thin air. Also, you will want to play around with collisions a bit. Anything that blocks the PathTrace channel will be walkable. Anything blocking RangeTrace will block line of sight. If bTraceForWalls is enabled in BP_GridManager, anything blocking WallTrace will block movement between tiles.

You will want to set up collisions appropriately for your meshes following these rules. You might also have to modify collision geometry for some meshes if they overlap tiles in weird ways, but that is on a case by case level

Hi ,

Back with an update after multiple testing narrowing down to damage not being calculated although strangely enough its only in the ability i made and the Take Damage take place after the queue action you’ve shown to me. Here are some screenshots as well.

Maybe my diagnosis was incorrect all along and it comes down to how you calculate and store your damage variable? Perhaps you should just send me the relevant parts of your code as a pastebin and I can inspect it myself.

Hey guys, is it possible to change the Grid Size X and Y of the BP_GridManager during runtime? I’m looking through the blueprints but struggling with figuring it out :slight_smile:

There are a few ways to go about this depending on what you’re after. It boils down to adding new values to the GridLocations TMap and GridEdges TMap, but the best implementation can vary quite a bit depending on how much you are adding. Could you describe your desired end result in more detail?

Hey there, I’m trying to build a simple editor, that players can place/change tiles and grid during runtime . So when the game is run, they can change grid size, and place the tiles - then save that level out or play through the level immediately

Update: i figured out that problem but now the problem still is that anyone that dies still lives despite the damage being calculated and they’re still being referenced on the grid manager. I’ve been trying to figure this out but the only solution i came up with was redo what i could in a separated saved file of the project but it still exist maybe i should just use the pastebin thing you linked to me to see if you can figure this out.

Thanks, EagleEyeGamma.

Another Update, it seems the ability with the repeating and damage modifier is somehow ignoring the ability to destroy the unit. I ran it through some more testing and figured it out the problem as the unit is not contacting the main BP_Unit to run the Destroyed Section of the Event graph or running the Animate Death Function somehow yet i ran it with the other abilities and it worked. I hope you can help me figure out why this is happening when this ability was working fine before.

This should do the job, I think. Not fully tested, and if you use multi-level stuff, big units etc. you will need to clear those appropriate maps as well. If you are not using a grid of spawned instanced static meshes (say you’re using manually placed meshes or terrain instead and hiding the grid), then the commented section is not necessary. Note that if you input a large grid size you are likely to drop some frames. Here is the pastebin for the code in the screenshot.

Ok, so I’ve replicated a simplified version of your ExecuteAbility function, where every attack is super effective (as I don’t think any of the other conditions should affect the bug you’re experiencing). However, everything seems to be working correctly on my end. Might you have changed some other part of the toolkit that is causing this? Could you try doing what I did and start a fresh ATBTT project, copy over your ExecuteAbility code and see if you get the same issue or not?

I want to use this as a foundation for a tile based digital board game.

The players will be able to move along the spaces a specific number of times, including going back to a space which counts as one of the number of times. I am happy I can turn off diagonal movement, I see that option in the video. Does this toolkit allow me to have the number of moves count when going forward and then going back to a previous space?

I see the spline while hovering with the mouse but you can’t hover with touch screens. How would navigating to a space to move work with touch on mobile?