[SUPPORT] Advanced Turn Based Tile Toolkit

This is correct. I use diamond visibility.

Ok, so diamond visibility was not really the cause of the problem (though it was necessary to reproduce the bug with the exact setup you pictured). The problem is that the AI naively assumes that any unit it finds during pathfinding can be reached and attacked from an adjacent tile. Normally this holds true. However, if the unit can pass through friendly units the pathfinding will find units that might be surrounded by other friendly units, meaning there is no unoccupied tile from which to attack. Sorry that you have been a bit of a guinea pig for the ā€œpass through friendliesā€ option, as it is not something I have tested as much as units with standard pathfinding.

The good news is that all this is fixed in the coming update. I have made big changes to the AI controller which makes it quicker, less convoluted and more stable, and in the process I also solved your problem by accident. However Iā€™m hoping you can live with this issue until the update is out. I could certainly think up a solution within the current framework, but it would be outdated as soon as the update is out.

My AI controller is significantly extended from the original, so itā€™d be preferable to know what I need to change to solve the issue with the system I have now, unless itā€™s something that I can easily integrate afterwards into my system.

Also isnā€™t the issue in pathfinding, since it affects players as well?

It should be something that is easy to integrate. It is a combination of several functions I now use to determine what units are reachable by the AI. These should be easy enough to replace with the old ones, but it will take some time to post all the nodes related to these new functions in this thread. Therefore I hope you can wait until the update is done. If you feel after the update is out that you will not want to use the new nodes for whatever reason Iā€™ll think up a custom solution for you.

Well yes, sort of. It is a problem with what units the pathfinding considers to be reachable. This could be fixed within the pathfinding function itself. However, that would require taking all units reached by the pathfinding and for each of them look at all surrounding tiles to determine if at least one of them is reachable and unoccupied (which is expensive). This can be done much more efficiently in the AI and Player controllers where it is possible to narrow down the amount of units you want to check. I would still prefer the Reachable Pawns Array to only contain the units which are actually reachable, though, so I will give this some more thought.

As long as itā€™s simple enough to integrate then it shouldnā€™t be a problem. That begs the question though, how long until you release the update?

The issue for me is that I would prefer the visible tiles to be rendered accurately.

Unfortunately, the pathfinding and visibility functions are one of the things Iā€™m not really familiar with at this point, but itā€™s my understanding that visibility is calculated after pathfinding, using the reachable tiles as a base to calculate whatā€™s visible using the unitā€™s range value. Would it be possible to simply remove occupied tiles from that list for calculating visibility, and then add them back in afterwards?

My aim is to release it along with UE4.15. They seem to be making quick progress, though, so maybe Iā€™m a bit optimistic :stuck_out_tongue:

You are absolutely right. I realized this shortly after my last post. I went to bed (it is pretty late in Norway), but kept thinking about it and then I came up with a solution. Couldnā€™t sleep without implementing it first, so here is my solution. Iā€™ll show the nodes without explaining too much as I need to get up for work early tomorrow. Iā€™ll explain then if you have any questions. There might also still be problems with this solution I have not seen yet, as Iā€™ve only had time for limited testing:

In Pathfinding (yes, that is a new function. Iā€™ll get to that next):

New function (left side):

New function (right side):

In Player Controller (in Event Graph. Under Display Path On Hover. Bottom pretty par right):

Also in Player Controller (by the Initialize Movement - Step 1 custom event)

AI should work with this solution without modification, even in the old version. Let me know if it solves your problems. I wonā€™t respond for at least another six hours, though :stuck_out_tongue:

Edit: the function above can possibly be made slightly more efficient for this specific purpose by limiting the tiles checked to the ones surrounding the potential targets. Getting these indexes requires using one of the visibility functions, though, so it would probably only be better for large movement ranges. This function also has other uses as a more efficient way to get all possible targets within range compared to the old version for the AI which is what I originally made it for)

Thanks for the help! :slight_smile:

This appears to have fixed the issue. My AI is not behaving like it should in some instances right now but Iā€™m not sure yet if itā€™s related to this fix, Iā€™ll figure out tomorrow whether itā€™s a result of this or not.

Unrelated to this and not game breaking, pass through friendlies pathfinding currently overlooks ideal tiles in some instances. For example:

https://imgtc.com/i/mk0wwXN.jpg

The circled unit just moved, and stopped on the space itā€™s currently sitting on. While you canā€™t see it in this image, offscreen to the left a couple spaces is a player unit that it was attempting to path towards. The path line is where Iā€™m guessing the pathfinding tried to direct it, but since the end space was occupied, it stopped where it did. However, it could have easily gone to the empty space marked by the arrow instead, and ended its turn closer to its target.

Ok, glad to hear it worked for the most part. Iā€™m a bit confused about your example, though. Why would the unit want to follow the path indicated by the long, bent arrow if the target is a couple of tiles off screen to the left?

I wouldnā€™t. Thatā€™s where Iā€™m guessing it tried to move. It should pick the empty space marked by the left arrow instead.

Alright Iā€™ve got a bit more into this. After this change, the first pawn to move on the AIā€™s turn will break and go to index 0 in the event that the unit is blocked. If the unit is not blocked, it will move correctly and attack it. Following pawns will simply remain still and do nothing if the path becomes blocked after the first pawn.

I still donā€™t know whether the cause is this change or not, Iā€™ll check back when I know more.

E:

Disconnecting the find units in sight from move array function fixes the issue of units not moving towards the target when theyre not close enough to attack it. So looks like thereā€™s something in there causing that issue.

I have no idea whatā€™s going on here lol.

That worked! Thank you. :slight_smile:

@Selentic: Yeah, sounds a bit confusing. The solution I gave you was a bit of a patch job using one of the new functions for something I did not originally intend it to be used for. I did not get the time to test it properly either and now Iā€™m away for the weekend and cannot test it out myself. I have not seen any such problems in the new update. I will take a closer look when I get back home and figure out if I can find a way to do this that also works for the old AI.

@Mewbits: Glad it worked! I think ideally what happens when you click a tile should not have to be dependent on what is displayed to the player, so I will put this on the list of minor things to be fixed.

At the very least it fixes visible tile rendering, for now I can just fall back on standard pathfinding. Iā€™ll keep at it for now and see if I can find a solution.

So, I have found another glitch with the toolkitā€¦ I have not modified the Find Tiles in Range event in any way. However, the minimum range doesnā€™t seem to be working. I wanted to find every index within a 15 tile radius, but not within a 5 tile radius. I then spawned a special tile on those spots, However, the tiles filled the entire 15 tile radius, instead of from 5 to 15.

Hereā€™s an example picture, from a new toolkit. It is called within the level blueprint.

91527ee7b965324fac4f875f969b79570efb9cb8.jpeg

On this version, it is minimum range of 3 and a range of 10. So the three inner rings should be empty, but if you look carefully, the tile cost 2 spawned there as well.

I donā€™t know if this has already been asked (Theres alot of comments on this post, too many to read through all the way!) but with the upcoming XCOM style gameplay update I was wondering if there are any plans to also add the feature of ā€˜selecting units from a listā€™ before the start of each map. Even a really bare bones basic system would be pretty awesome. The gameplay is a priority for sure, rightly so, but something small like that really would be a great time saver in testing.
Also just a suggestion for a few small features if thats okay;
1- Make an option to Start a map without units automatically selected each turn, and instead you must manually select a unit to control them. This obviously would only affect human players not AI and as an option it wouldnā€™t effect those who wouldnā€™t like that as they can have is disabled.
2- To add to the last suggestion, have a button to end a players turn early, even if they havenā€™t moved all their pawns.
3- Last suggestion, before completing a turn for a pawn (movement or attack) have a UI or something to show a Proceed/Cancel option rather then just doing it. Again as an boolean option, so those who would prefer the instant-Click method rather then the planning method wouldnā€™t be affected.

Even if none of these suggestions are taken into consideration, thank you again for the awesome kit. Its amazing how much blueprints can accomplish without a single line of C++, even more amazing that some people, like yourself, can already understand it so masterfully. Itā€™s not crazy to think that in 10 years time there might be multiple visual coding languages that are just as powerful and flexible as classic coding languages, making game design accessible to everyone with interest.

Ok, let me know if you figure something out. As mentioned I want to look at this as soon as possible and make sure it is not a bug that is carried over into the new update, but I am away visiting the in-laws this weekend. Iā€™ll get working on it when I return.

That is odd. From your screenshot it seems that there is a second problem as well, where tiles are not spawned at the first index of even rows. Does this happen in a fresh project? It looks like a bug Iā€™ve seen before, but one that I fixed a long time ago.

Thanks for the suggestion, Malibu Lizard. This is something that several other people have requested and I did consider adding something like this to the game example in the coming update. However, Iā€™ve had to stop myself from constantly adding new features so that I can get this update done. What was originally planned to be just a few small additions quickly ballooned into a big list of complex new features so that Iā€™m way past the date I planned to release the update. I will be sure to put this on the list of things to add in the following update, though.

All these are good suggestions and are all related to giving the user more control over turn order. This is a part of the toolkit Iā€™ve long wanted to make more easy to adapt and modify, so this is all on my to-do list. Though again not for the coming update, but the one after.

Thanks and youā€™re welcome :slight_smile: I first started making grid based pathfinding in UE4 mostly to test out the capabilities of blueprints and determine whether they could realistically be used to make a full game (early on there was a ton of scepticism regarding blueprints and people were saying that you should never use it for anything serious). My experiment got the attention of people on this forum who had thought about making TBS games and slowly grew into this toolkit. Blueprints are a fantastic tool for scripting and the way you create a visual layout of nodes seems to mesh well with my way of thinking and creative process. With blueprint nativization that was added a couple of UE4 versions ago the speed of blueprints has increased substantially, making it even easier to justify using blueprints for just about everything. Iā€™ve become very good at certain kinds of blueprint scripting; mainly the parts involved with manipulating arrays, but I still have many areas that I know very little. Making this toolkit has made me very specialized, and I still have only novice to intermediate knowledge about animation blueprints, UI and material nodes, for instance. But as Iā€™m beginning to become satisfied with how the underlying mechanics of the toolkit work Iā€™ll be looking into adding features that require other such skillsets. Making a good UI for selecting units, ending turns etc. is one such feature.

Yes, before I made this example project, I deleted my local content and downloaded a fresh new version of the toolkit, to make sure it was the most recent version. Then I made the changes within it. Itā€™s the same project I sent you over email.

Alright Iā€™ve had a bit more time to go at it, and Iā€™ve fixed a few errors I made in my ai controller that may have been affecting this issue. After a quick run through which is by no means conclusive, this appears to be working correctly again. Iā€™ll get some more proper testing in tomorrow figure out one way or another whether itā€™s working.

Ok, thanks for taking the extra steps in testing it out and sending me a project. I will take a look at it when Iā€™m back on Monday.

Ok, good to hear. Iā€™ll do some testing myself in any case. I want to eliminate all serious known bugs before sending Epic the update.

Hello, Iā€™ve just bought this tool kit, as itā€™s what I think, the best starting point for my ideea and I would like to thank you for creating it.
Now, Iā€™ve done a bit of testing around , so fo the next few weeks, I will probably be everyday on this thread asking for your help in solving my noob problems. So, first issue I have, and Iā€™m wondering if anyone else came across it , itā€™s that when Iā€™m trying to export a blank new , fresh project ( fresh as in itā€™s just this toolkit in there, nothing else done or modified ) , I get a error in the packing procces ( here is the link http://s000.tinyupload.com/?file_id=31203541819716128527 to download a txt fille with the whole log in there ). The project packing settings were : distribution, windows 64bit.

Thanks for any ideeas you might have, this is a no rush problem, but it would be nice to know it can be fixed before I spend a long time over something that canā€™t be packed.