Announcement

Collapse
No announcement yet.

[SUPPORT] Advanced Turn Based Tile Toolkit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    @OperatorCrux: Ok, good you got it working. No, there is no reason to keep the originals of the animated units or animation blueprints. They are mostly examples of one way to animate units, and other blueprints do not depend on their functionality.

    Originally posted by ienjoywhiskey View Post
    Hi there! Just bought this on the Marketplace, great job!

    I'm looking to see if I can modify the setup a bit so that the BP_Grid_Manager and units are generated at runtime. I'm interested in adding some factory/unit construction functionality and I was wondering if you had any tips on doing that. Or is your setup mostly designed to just be dropped into the editor and everything done via construction script, which I think is not fired if spawned at runtime though I could be wrong.

    Thank you!

    Edit: I've determined that the Grid Manager needs to exist when the game starts or a lot of stuff breaks, as far as I can tell. Perhaps I'll have the grid manager manually placed in -- however, I am having trouble spawning units (Using the Spawn Unit function in the Grid Manager) and having them interactible in the game. The unit spawns but I can't click it or do anything. Any ideas? Thank you!

    Slightly unrelated to the spawn unit problem, I'm also unsure of how to change the size of the grid (X and Y) after runtime. For example, I'd like to deploy a saving/loading system where you can load up a map that is say, 5x5. But if the grid manager is the default 3x3 at begin play, I'm not sure if there's a way to change that dynamically.

    Double edit: Sorry for all the edits! It appears the spawned unit behaves normally if there is at least one manually placed unit. Do you know if there is a way to allow a spawned unit to be selected and used when there are no units at all existing when the game starts?
    Hi ienjoywhiskey, and welcome You are right in your observation that ATBTT is not ideally set up for spawning the grid manager after setup. I'm meeting the challenge, though, and have hacked together a working solution. I'll probably add something more robust to the actual toolkit in the future, but this should help you get started. It took some experimentation, but it turned out I didn't need to change all that much.

    First I've removed the event begin play event of ATBTT_Game_Mode and replaced them with a new event called "Start Game", so we have control on when we want to start it up. I've set the default pawn to be something else than BP_GridCamera (I went with spectator pawn) and have made these additions to the event graph of ATBTT_PlayerController:



    With this setup you press 1 to place the grid manager in the game (make sure to set any variables you want to alter when spawning to "Expose on Spawn" in their variable properties, which I have done with GridSizeX and GridSizeY in this example). When you press 2 you spawn a melee player unit at the tile you are hovering over. When you press 3 you start the game by calling the Start Game event in ATBTT_GameMode (make sure to remove the call to ActivateGridManager from the event graph of ATBTT_GameMode so you don't do it twice).

    This setup is obviously too hardcoded, but you can make it a lot more flexible with a few additions.

    Hope I remembered to describe all the steps so you can get it working. Let me know if it works and if it is what you were trying to do
    The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

    Comment


      Awesome! Thank you man. I really appreciate you taking the time to RnD that. I'll give it a shot later on tonight.

      I had one other unrelated question...
      -Is there an easy way to "deselect" units when it's your turn? I know currently you can switch between your units by clicking on them, but I'd like an option to right-click and have no units selected. I tried setting it up myself last night by clearing the current pawn variable but it kinda borked a few things as a result.

      Thanks again for your awesome support!

      Edit: So the runtime setup you taught me worked like a charm! Thanks again. I think I also figured out my above question about deselecting the unit -- basically I'm tweaking the flow of the Mouse click input to allow for deselecting/selecting units. It's going to be a long road to convert this to more of an Advance Wars - style setup with unit building/capturing but it's a great place to start.

      Double Edit again: So I do have a question that is stumping me currently. Where in the Pathfinding functions would it be best to change out the goal actor/location of the pathfinding? For example, what if I wanted the AI to search for a particular grid/tile index rather than just an enemy with the lowest HP. Something dynamic so I can change the goal tile as needed. Looking through the pathfinding functions, I can't seem to find where that goes and I'm afraid to touch anything :P

      Thank you!
      Last edited by VaultedSky; 09-22-2017, 01:13 AM.

      Comment


        @ienjoywhiskey: Glad it worked

        For your question of changing the goal actor/location, I probably would not do that in the pathfinding function itself. I'd run pathfinding as usual, and then loop over the returned tiles to find the desired target. You could do this in the AI controller. The Pathfinding function outputs the CanMoveToArray and IndexCanMoveToArray among others. The CanMoveToArray is the size of the entire grid, while the IndexCanMoveToArray only contains the tiles found in the previous pathfinding function.

        For finding a specific tile I'd do a for loop with break on the IndexCanMoveToArray, check the cost value of each array element against the desired index value, and break the loop and return true if the grid index is found. If it returns true, we know that the grid index is within movement reach of whatever unit last ran the pathfinding function, at which point we can order said unit to move to this index.
        The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

        Comment


          Ahh, thank you Monokkel! That makes a lot of sense. Thanks for the explanation.

          Apologies for all the questions, but I ran into another one as a result of moving to a runtime grid generation system.
          So I've made a Tile_Wall duplicate actor and added a bunch of functionality to essentially turn it into a unit factory. When I click on a Widget I put on top of it, a friendly guy spawns at the index in front of it. No issues there.

          But the Tile_Wall can be walked through / into ingame, even though the edge costs are all 0 which should make it a blocker. I've made sure all the stuff in the construction scripts is copied over into the event graph and called when the tile is spawned, and it correctly snaps to its nearest tile and assigns that value to the "Index" variable. But it still can be passed through and walked into. Not sure if there's an additional step I should be taking to make sure it talks to the pathfinding -- any ideas?

          Anyways, thanks again for the help my man. I hope I haven't been too annoying with all these questions

          Comment


            @ienjoywhiskey: Don't worry, I'm not bothered at all. This is something I'd like to support in the future, so thinging through it all now is helpful to me as well.

            So the way walkability works in ATBTT is through an array containing the "edges" of all tiles. The Edge Array is a grid sized array of arrays, where each nested array cointains a struct saying which tile a tile is connected to and what its movement cost is. If the Edge Array is not manipulated when you place a unit factory, the pathfinding will ignore it. If your unit factory is a child of the Tile blueprint you can use the function Spawn Tile in BP_GridManager, which will automatically update the edge array with the edge values contained in the tile actor. Try doing this and see if it works.
            The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

            Comment


              Originally posted by Monokkel View Post
              @ienjoywhiskey: Don't worry, I'm not bothered at all. This is something I'd like to support in the future, so thinging through it all now is helpful to me as well.

              So the way walkability works in ATBTT is through an array containing the "edges" of all tiles. The Edge Array is a grid sized array of arrays, where each nested array cointains a struct saying which tile a tile is connected to and what its movement cost is. If the Edge Array is not manipulated when you place a unit factory, the pathfinding will ignore it. If your unit factory is a child of the Tile blueprint you can use the function Spawn Tile in BP_GridManager, which will automatically update the edge array with the edge values contained in the tile actor. Try doing this and see if it works.
              I
              Ohhh, I didn't know there was a Spawn Tile function already set up! I should have looked for that. Yep, works perfectly. Thanks again, you rock!

              Comment


                Originally posted by ienjoywhiskey View Post
                Ohhh, I didn't know there was a Spawn Tile function already set up! I should have looked for that. Yep, works perfectly. Thanks again, you rock!
                There are lots of functions in the toolkit at this point, and I might even have forgotten to cover that one in my tutorials. After the next update I'm planning on making a few new tutorial videos focusing on key concepts of ATBTT, such as the edge array/pathfinding. Hopefully this will make these sorts of things easier to grasp quickly.
                The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

                Comment


                  That sounds great! Thanks man for the continued support.

                  I had two other questions that occurred to me over the weekend..

                  -I know you are in the middle of trying to get networked multiplayer working, when you release that update do you expect it would be relatively easy to drop into an existing project? Or does it change so much in how blueprints are handled that it almost would be better to just start fresh and try to rebuild any custom functionality with the old project as reference?

                  -I've gotten the hang of the Spawn Tile functionality at runtime and it's working great, I was wondering -- what do you consider the cleanest way to delete spawned tiles and have the edgecosts/pathfinding update? Does simply destroying that actor keep the edge costs or does it update dynamically and reset the edge costs of that tile back to the default?
                  For example, if I'm at runtime and want to add a wall blocker at this tile, but I changed my mind and wanted to delete it and replace it with a 3 Cost tile.

                  I'm away from my workstation at the moment so I can't fiddle with it myself today

                  Thanks again!

                  Comment


                    ienjoywhiskey: Hey, sorry for the late answer. I'll try to answer your questions.

                    For your first question, I think it will not be that straightforward to drop an existing project into the new update. It will probably be easiest to copy over any changes you mande one by one and testing each step/modifying as necessary. The toolkit has not changed so much that porting added features should be that difficult, but even the fact that I've changed quite a few variable and function names to better comply with Epic's scripting standards means that directly copying over will not work in most cases.

                    For your seestion, the MakeTilePassable function should work well for what you are trying to do. Run it for the appropriate tile after destroing the actor occupying it. After that you can modify its tile costs either by using Spawn Tile for a tile with the correct indexes, or edge by edge by using Get Adjacent Indexes and Set Edge Cost.
                    The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

                    Comment


                      Hey great kit, the VR map in particular is excellent and I hope this functionality continually gets upgraded. One idea is the ability to spawn pickup drops /units.

                      Anyway I noticed you mentioned turn based pathfinding is mostly for performance. What about if all units could move around freely except with a cool down timer? This would naturally limit the pathfinding and the cooldown could be tuned per unit so that theres not to much pathfinding going at at any one time overall.

                      This would also be really cool strategy wise as you have to track all your units at once.
                      Atoms4D - Indie VR Game atoms4d.com *site needs updating(soon)*
                      XAXISvr - A Marketplace for VR Dev's: xaxisvr.com
                      Owen Prescott - Official Concept Art & Design: owenprescott.com

                      Comment


                        Originally posted by owenprescott View Post
                        Hey great kit, the VR map in particular is excellent and I hope this functionality continually gets upgraded. One idea is the ability to spawn pickup drops /units.

                        Anyway I noticed you mentioned turn based pathfinding is mostly for performance. What about if all units could move around freely except with a cool down timer? This would naturally limit the pathfinding and the cooldown could be tuned per unit so that theres not to much pathfinding going at at any one time overall.

                        This would also be really cool strategy wise as you have to track all your units at once.
                        Thanks! VR features is something I really want to work on in the future. When I finally get around to making my own game I want it to have VR-support, so this is something I'll steadily be improving.

                        You can already spawn units. Use the Spawn Unit function in BP_GridManager.

                        Though one of the reasons I don't have real time pathfinding is performance, a just as big reason is that having to accound for the possibility of real time movement in every feature I add would slow me down tremendously and probably make the blueprints bloated and hard to work with. Keeping everything turn based means I can keep some assumtions constant. I'm not saying it would be impossible to alter the toolkit to allow for this, but for me to include it as a supported mode along with everything else is much more difficult.
                        The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

                        Comment


                          Hey,

                          I've been going through the code and I found that "Show Crosshairs" shows the units we'll be able to attack if you move to that tile, now I can't seem to find a function or bool to set where I can stop the target tiles, so all tiles you will be able to attack from that tile. Is there a way we can visualize the tiles that'll be target-able?

                          Marketplace Asset - Economy Kit; Marketplace Asset - Notification Kit; Marketplace Asset - Achievepedia; Marketplace Asset - Player Stats Kit; Marketplace Asset - Photomode;
                          Marketplace Asset - Interaction Kit; Marketplace Asset - Turret Kit; Marketplace Asset - Character Stats Kit; Marketplace Asset - Smooth Camera Kit; Plugin - Toggl Plugin;
                          Hire us here; Panda Studios, Game development company.; Official Unreal Engine Game Jam Sponsor

                          Comment


                            Originally posted by Panda Studios View Post
                            Hey,

                            I've been going through the code and I found that "Show Crosshairs" shows the units we'll be able to attack if you move to that tile, now I can't seem to find a function or bool to set where I can stop the target tiles, so all tiles you will be able to attack from that tile. Is there a way we can visualize the tiles that'll be target-able?
                            Hi there! The "Show Crosshairs" functionality is intentionally set up so that it does not find all tiles in range and then filter out the target units. Instead it just look at the tiles containing units, which requires a lot fewer calculations in almost all cases. This is the reason you have not been able to find any bool or function to switch off such a filter.

                            So to get the game to display all tiles in range you'll need to make some additions. The blueprint nodes below have been connected in ATBTT_PlayerController to where the switches from ShowCrosshairs normally lead (far bottom right of the event graph). In the first part I use the Find Tiles In Range function to get and display all tiles in range of the hovered tile. The array manipulation on either side is to make it so the range arrays are set back to what they were before running the function, as these arrays inform what tiles can be attacked, and we want to use the function just for displaying tiles in our case.



                            Lastly we need to make sure that the displayed tiles are removed when we move the cursor to a new tile. These nodes are connected in the absolute bottom right of the event graph of ATBTT_PlayerController. I'm assuming you're using meshes for tiles in sight range in this case. If you're using decals instead, take a look in the ClearAllInRangeMarkers function in BP_GridManager to see how to do this with decals instead.



                            Even though these calculations are fairly quick, if you have units with very large movement ranges (especially if you're using multi-layer grids) and have not nativized the blueprints you could potentially see a drop in frame rate if the player quickly runs his/her mouse over multiple tiles in rapid succession. If you experience this, then I would add a tiny delay when hovering over a tile before finding the tiles in range (cancelling running the function if the hovered tile after the delay is not the same as the one before the delay).

                            Here is how it looks in action. Hope this is what you were trying to achieve:

                            https://imgur.com/a/ga7a4
                            The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

                            Comment


                              Originally posted by Monokkel View Post
                              ienjoywhiskey: Hey, sorry for the late answer. I'll try to answer your questions.

                              For your first question, I think it will not be that straightforward to drop an existing project into the new update. It will probably be easiest to copy over any changes you mande one by one and testing each step/modifying as necessary. The toolkit has not changed so much that porting added features should be that difficult, but even the fact that I've changed quite a few variable and function names to better comply with Epic's scripting standards means that directly copying over will not work in most cases.
                              Thank you for the info! Do you have an idea when the networked multiplayer update might be ready? No worries if it's awhile out, just want to see if I should hold out on more custom changes and just wait for the update to continue.

                              Comment


                                Originally posted by ienjoywhiskey View Post

                                Thank you for the info! Do you have an idea when the networked multiplayer update might be ready? No worries if it's awhile out, just want to see if I should hold out on more custom changes and just wait for the update to continue.
                                To answer in boring, vague marketing terms: "weeks, not months" :P It is mostly cleanup at this point, but new bugs keep popping up while I'm testing, so it is hard to predict exactly when I get it bug free and with all features working perfectly. A deadline I've hanging over me for my PhD has also slowed me down a bit.
                                The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

                                Comment

                                Working...
                                X