Announcement

Collapse
No announcement yet.

[SUPPORT] Advanced Turn Based Tile Toolkit

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

    What you are asking is not exactly my area of expertise, but I'll try to help you as best I can. If you want to use a polyhedric base mesh and create a sphere out of multiple arranged meshes, you could do it the same way I do it with a flat grid. I use some pretty basic math to calculate the position of each tile. Basically I multiply the X index of an array item by the X width of a tile to set its X location and multiply the Y index with the Y length of a tile to set its Y location (UE4 does not support 2D arrays so I fake this with a 1D array which makes it a bit more complicated). Hexagonal grid are a tiny bit more complicated, mostly because each row needs to be offset by half a tile width. You could do the same thing, the only thing being different is the formula you use for calculating the location and rotation of each tile in 3D space. The formula for this is more complicated, of course, but the concept is the same.

    As noted earlier you would need to rewrite a few other things to get this working properly with the toolkit once you've got the meshes aligned properly. How to determine which tile index can be found at what location vector is one of these (you would have to do something similar to what you do when setting the location of each tile, just in reverse). Setting up which tiles share edges with other tiles (can be moved between) is something you would also need to do. To achieve this you would need to modify the Add Viewport Terrain to Arrays function in BP_GridManager. You would also need to change how visibility is calculated, as the current solution has some in-built assumptions about the structure of the grid. There are surely other things that also need to be changed (setting the rotation of units while moving comes to mind. This one should be simple, though), but these are the main obstacles I can think of.

    Like I said, this is no small task, but it is achievable. I'll be looking forward to seeing your progress. Feel free to post questions in this thread at any time.
    Advanced Turn Based Tile Toolkit (Marketplace - Support)

    Dungeon Crawler Toolkit (Marketplace - Support)

    Discord

    Comment


      Originally posted by Monokkel View Post
      What you are asking is not exactly my area of expertise, but I'll try to help you as best I can. If you want to use a polyhedric base mesh and create a sphere out of multiple arranged meshes, you could do it the same way I do it with a flat grid. I use some pretty basic math to calculate the position of each tile. Basically I multiply the X index of an array item by the X width of a tile to set its X location and multiply the Y index with the Y length of a tile to set its Y location (UE4 does not support 2D arrays so I fake this with a 1D array which makes it a bit more complicated). Hexagonal grid are a tiny bit more complicated, mostly because each row needs to be offset by half a tile width. You could do the same thing, the only thing being different is the formula you use for calculating the location and rotation of each tile in 3D space. The formula for this is more complicated, of course, but the concept is the same.

      As noted earlier you would need to rewrite a few other things to get this working properly with the toolkit once you've got the meshes aligned properly. How to determine which tile index can be found at what location vector is one of these (you would have to do something similar to what you do when setting the location of each tile, just in reverse). Setting up which tiles share edges with other tiles (can be moved between) is something you would also need to do. To achieve this you would need to modify the Add Viewport Terrain to Arrays function in BP_GridManager. You would also need to change how visibility is calculated, as the current solution has some in-built assumptions about the structure of the grid. There are surely other things that also need to be changed (setting the rotation of units while moving comes to mind. This one should be simple, though), but these are the main obstacles I can think of.

      Like I said, this is no small task, but it is achievable. I'll be looking forward to seeing your progress. Feel free to post questions in this thread at any time.

      Thank you - I'm going to do a bit more research. I'll get back to you when I've made some progress!

      Comment


        Hey Monokkel. I've built some unit spawners that direct units they spawn to a specific tile.



        They work flawlessly, when only one unit is being spawned and directed to move. However if I try to spawn more than one, and direct them to different tiles they break visually, and they end up just becoming stacked on top of each other in the same index visually due to not running the pathfinding per unit.

        Having a hard limit of only moving one unit at a time isn't a huge deal for this situation, since just spawning them on specific tiles and not moving them works perfectly, but it does make things like cinematics where I would want multiple units moving together not viable. Do you have any suggestions for how to get around this?
        Anime Shading Model - Twitter

        Comment


          [MENTION=645005]andreasmaragakis[/MENTION]: Looking forward to it! Good luck

          [MENTION=16997]Selentic[/MENTION]: Ok, took me a bit, but I've got something to get you most of the way. The toolkit is built upon the notion that everything is truly turn based, and having multiple units act at the same time breaks this rule. I'm slowly trying to remove this limitation, but at the moment it takes a bit to work to achieve something like this.

          The more specific reason for the problem you are seeing is that all units are referencing the same Path Index Array and spline in BP_GridManager and so they get stacked on top of each other. To fix this every unit need to have their own spline and path index array which is set up when they begin movement.

          Unit_Parent already have their individual spline reference variables, just to cut down on casting and you can use this to set up a reference to a specific spline for this unit. For this I've created a new blueprint called BP_PathSpline that is a blank actor with a spline which I spawn at the start of unit movement and delete at the end of movement. There are probably more elegant ways to do this, but it is a quick and workable solution. Here is the part in the Event Graph of Unit Parent where I copy the spline held in BP_GridManager over to the new BP_PathSpline actor and also copies the Path Index Array from BP_GridManager over to a local array:

          Click image for larger version

Name:	xvrqMmg.png
Views:	1
Size:	319.9 KB
ID:	1120540

          After this you will need to replace all references in Unit_Parent to Path Index Array from BP_GridManager with the Local Path Index array. You will also want to destroy BP_PathSpline at the end of movement. Also, I've been a bit silly and set it up so that units are removed from the Unit Array in ATBTT_PlayerController instead of in the Event Graph of Unit_Parent which would make more sense (I'll change this in the next update), so you will also need to add this after Begin Movement in the event graph of Unit Parent:

          Click image for larger version

Name:	XRKSv5O.png
Views:	1
Size:	186.8 KB
ID:	1120545

          I tried this out with the same nodes you posted a screencap of above and it seemed to work fine. There might be quite a few hidden problems since I haven't had time to test it properly amid all the Christmas cheer, but if you meet any other tricky obstacles just let me know. As mentioned I want to take the toolkit in this direction in the future so I'll be interested in hearing of any problems you might encounter.
          Advanced Turn Based Tile Toolkit (Marketplace - Support)

          Dungeon Crawler Toolkit (Marketplace - Support)

          Discord

          Comment


            Originally posted by Monokkel View Post
            [MENTION=16997]Selentic[/MENTION]: Ok, took me a bit, but I've got something to get you most of the way. The toolkit is built upon the notion that everything is truly turn based, and having multiple units act at the same time breaks this rule. I'm slowly trying to remove this limitation, but at the moment it takes a bit to work to achieve something like this.

            The more specific reason for the problem you are seeing is that all units are referencing the same Path Index Array and spline in BP_GridManager and so they get stacked on top of each other. To fix this every unit need to have their own spline and path index array which is set up when they begin movement.
            Ah so that's where the problem was. I was confused because each unit seemed to already have their own spline set during pathfinding.


            Originally posted by Monokkel View Post
            Unit_Parent already have their individual spline reference variables, just to cut down on casting and you can use this to set up a reference to a specific spline for this unit. For this I've created a new blueprint called BP_PathSpline that is a blank actor with a spline which I spawn at the start of unit movement and delete at the end of movement. There are probably more elegant ways to do this, but it is a quick and workable solution. Here is the part in the Event Graph of Unit Parent where I copy the spline held in BP_GridManager over to the new BP_PathSpline actor and also copies the Path Index Array from BP_GridManager over to a local array:

            [ATTACH=CONFIG]122825[/ATTACH]

            I tried this out with the same nodes you posted a screencap of above and it seemed to work fine. There might be quite a few hidden problems since I haven't had time to test it properly amid all the Christmas cheer, but if you meet any other tricky obstacles just let me know. As mentioned I want to take the toolkit in this direction in the future so I'll be interested in hearing of any problems you might encounter.
            Excellent, thank you. I've got a couple other things I have to finish up before I focus on this part again, but those should be done shortly. Once I'm done with those I'll let you know how this works.

            Originally posted by Monokkel View Post
            After this you will need to replace all references in Unit_Parent to Path Index Array from BP_GridManager with the Local Path Index array. You will also want to destroy BP_PathSpline at the end of movement. Also, I've been a bit silly and set it up so that units are removed from the Unit Array in ATBTT_PlayerController instead of in the Event Graph of Unit_Parent which would make more sense (I'll change this in the next update), so you will also need to add this after Begin Movement in the event graph of Unit Parent:

            [ATTACH=CONFIG]122830[/ATTACH]
            Oh man, it's been a while since my unit_parent looked like that. I rewrote all that a while ago. That said, I spent more time than to admit when I started modifying things trying to find the part where it was writing the end position into the pawn array, though I thought it made more logical sense in the controller, but that might just be due to the context from the kind of game I'm working on. As long as they're together though it should cut down on confusion for new people working with this.
            Anime Shading Model - Twitter

            Comment


              Originally posted by Selentic View Post
              Ah so that's where the problem was. I was confused because each unit seemed to already have their own spline set during pathfinding.
              Yeah, so was I. That was my original intention for adding the spline variable to Unit_Parent, but it seems like I only added a reference to the PathSpline in BP_GridManager. Looking into this now made me realise it did not work the way I intended (it is still somewhat helpful in reducing the amount of castingm though). I'll think about how I'll go about implementing separate unit splines in the future. There might be a more elegant way.

              Originally posted by Selentic View Post
              Excellent, thank you. I've got a couple other things I have to finish up before I focus on this part again, but those should be done shortly. Once I'm done with those I'll let you know how this works.
              No problem. It should at the very least work for cinematic sequences.

              Originally posted by Selentic View Post
              Oh man, it's been a while since my unit_parent looked like that. I rewrote all that a while ago. That said, I spent more time than to admit when I started modifying things trying to find the part where it was writing the end position into the pawn array, though I thought it made more logical sense in the controller, but that might just be due to the context from the kind of game I'm working on. As long as they're together though it should cut down on confusion for new people working with this.
              I guess using either the Player Controller or the Pawn's blueprint could make sense, but it should still probably be handled by one or the other and not a combination of both. Since the nodes for constantly updating the unit's index during movement is natural to contain in the event graph of Unit_Parent I think it makes sense that the beginning and end of movement is also handled here. Especially since the player controller is set up to only control the current active unit, and one might want to move a different unit on one unit's turn (possibly pushing it or commanding it to move). Containing it with the rest of the movement nodes in Unit_Parent is the best way to make sure that whenever a unit moves for whatever reason it is reflected in the Pawn Array.
              Advanced Turn Based Tile Toolkit (Marketplace - Support)

              Dungeon Crawler Toolkit (Marketplace - Support)

              Discord

              Comment


                Hi Monokkel

                I have been having a strange glitch lately where after adding in new events and functions to the toolkit, all of my unit's attributes are reset to the default unit parent attributes. I have also been having a strange glitch where the game doesn't order the pawns in initiative correctly. I added a initiative bar to my screen, that places an icon of each pawn on the screen in the order of the initiative array. Could that be causing the problem?

                Has anyone else had this problem?

                Comment


                  Originally posted by Mewbits View Post
                  I have been having a strange glitch lately where after adding in new events and functions to the toolkit, all of my unit's attributes are reset to the default unit parent attributes.
                  This is a widely reported bug with the engine (googling for it will find you about 8~ answerhub pages dating back to 2014 with no found solution) which I've been facing too. For no apparent reason the engine will reset children of blueprints at random to their default values. The issue also affects blueprints placed within your levels that have had attributes changed, where sometimes you'll open it up and find that all custom data for every blueprint has been reset.

                  I've been dealing with this by simply zipping up a copy of my blueprints whenever I make significant changes to them so that when it occurs I can just reload those.

                  Originally posted by Monokkel View Post
                  No problem. It should at the very least work for cinematic sequences.
                  I got around to testing this out. The units no longer stack on top of each other, and end up in their appropriate spots, but all past the first just appear there without actually moving. I'll look into this more tomorrow.
                  Last edited by Envieous; 01-01-2017, 12:29 AM.
                  Anime Shading Model - Twitter

                  Comment


                    Originally posted by Selentic View Post
                    This is a widely reported bug with the engine (googling for it will find you about 8~ answerhub pages dating back to 2014 with no found solution) which I've been facing too. For no apparent reason the engine will reset children of blueprints at random to their default values. The issue also affects blueprints placed within your levels that have had attributes changed, where sometimes you'll open it up and find that all custom data for every blueprint has been reset.

                    I've been dealing with this by simply zipping up a copy of my blueprints whenever I make significant changes to them so that when it occurs I can just reload those.
                    Thanks for the information Selentic. I'll have to do that too. Glad to know it wasn't me messing it up somehow. Hope they fix this error soon.

                    I have another question: Is there a function for changing the cost of a specific edge at run time?
                    Last edited by Mewbits; 01-02-2017, 01:04 PM.

                    Comment


                      Originally posted by Mewbits View Post
                      Hi Monokkel

                      I have been having a strange glitch lately where after adding in new events and functions to the toolkit, all of my unit's attributes are reset to the default unit parent attributes. I have also been having a strange glitch where the game doesn't order the pawns in initiative correctly. I added a initiative bar to my screen, that places an icon of each pawn on the screen in the order of the initiative array. Could that be causing the problem?

                      Has anyone else had this problem?
                      As mentioned by Selentic this is a problem with the Engine and not the toolkit. It is pretty annoying to be sure, but nothing I can do anything about. I'm more uncertain about the problem with initiative order. Could you be a bit more specific about what sort of error you are seeing? How is the ordering incorrect?

                      Originally posted by Selentic View Post
                      I got around to testing this out. The units no longer stack on top of each other, and end up in their appropriate spots, but all past the first just appear there without actually moving. I'll look into this more tomorrow.
                      It worked when I tried it out. I hope I didn't forget something in my explanation. The error you are seeing seems to suggest that some part of the units' event graphs are still referencing either the spline or path index array in the grid manager. Take a through look through unit_parent's event graph.

                      Originally posted by Mewbits
                      Is there a function for changing the cost of a specific edge at run time?
                      Yep, there are a few functions listed under Utility in BP_GridManager. Set Edge Cost is probably the one you're looking for, but there is also Remove Tile Edge, Make Tile Impassable, Remove Tile Edge Both Ways, Add Edge and Add Edge Both Ways.
                      Advanced Turn Based Tile Toolkit (Marketplace - Support)

                      Dungeon Crawler Toolkit (Marketplace - Support)

                      Discord

                      Comment


                        Originally posted by Monokkel View Post
                        As mentioned by Selentic this is a problem with the Engine and not the toolkit. It is pretty annoying to be sure, but nothing I can do anything about. I'm more uncertain about the problem with initiative order. Could you be a bit more specific about what sort of error you are seeing? How is the ordering incorrect?
                        It will allow the player to move two units, then switch over to move the entire enemy team, then allow the player to move the remainder of their team members. In the next round, everything is back to normal and all the players can move, then all the enemies, and so on and so forth.

                        Originally posted by Monokkel View Post
                        Yep, there are a few functions listed under Utility in BP_GridManager. Set Edge Cost is probably the one you're looking for, but there is also Remove Tile Edge, Make Tile Impassable, Remove Tile Edge Both Ways, Add Edge and Add Edge Both Ways.
                        Sounds like remove tile edge both ways is what I want. However it asks for index one and index two. I want to remove the east edge of the current tile and the west edge of the tile above it. Index 1 is the index of the current tile, correct? How do I find the index of the tile above the current tile?

                        Thank you for your patience and answers, by the way.

                        Comment


                          Originally posted by Mewbits View Post
                          It will allow the player to move two units, then switch over to move the entire enemy team, then allow the player to move the remainder of their team members. In the next round, everything is back to normal and all the players can move, then all the enemies, and so on and so forth.
                          Odd. And the only way you've affected the initiative order is by using it to inform the UI? But if you are just getting values from the initiative order array and not modifying it then nothing should change. What are the initiative values of the units? What do you see if you run a ForEach loop through the Initiative Order array at the start of the game?

                          Originally posted by Mewbits View Post
                          Sounds like remove tile edge both ways is what I want. However it asks for index one and index two. I want to remove the east edge of the current tile and the west edge of the tile above it. Index 1 is the index of the current tile, correct? How do I find the index of the tile above the current tile?
                          If you are removing the edge both ways it does not really matter which is index one and which is index two. To get the index of an adjacent tile you take the tile's index and either add or subtract a value depending on what tile you want. For a square grid this is as follows:

                          north: index - GridSizeX
                          east: index +1
                          south: index + GridSizeX
                          west: index -1

                          If you visualize it as a grid it should become obvious. Here is a 3*3 grid (meaning it has a GridSizeX of 3).

                          1 2 3
                          4 5 6
                          7 8 9

                          To get the index north of index five that would be 5 - 3 (GridSizeX) = 2. The east index would be 5 + 1 = 6 etc. Hex grids are a bit more complicated since it varies depending on if you are on an odd or even row. Are you using a hexagonal grid?

                          Originally posted by Mewbits View Post
                          Thank you for your patience and answers, by the way.
                          Happy to help!
                          Advanced Turn Based Tile Toolkit (Marketplace - Support)

                          Dungeon Crawler Toolkit (Marketplace - Support)

                          Discord

                          Comment


                            Originally posted by Monokkel View Post
                            Odd. And the only way you've affected the initiative order is by using it to inform the UI? But if you are just getting values from the initiative order array and not modifying it then nothing should change. What are the initiative values of the units? What do you see if you run a ForEach loop through the Initiative Order array at the start of the game?
                            Yes, all I do is grab from the initiative order to place widgets into my UI.

                            After running a for loop with appended object name to the initiative (index) number, this is what it prints out:

                            Unit _Player_Warrior is Initiative 8
                            Unit _Player_Skirmisher is Initiative 7
                            Unit _Player_AOE is Initiative 6
                            Unit _Enemy_Ranged is Initiative 5
                            Unit _Enemy_Ranged_2 is Initiative 4
                            Unit_Enemy_Melee is Initiative 3
                            Unit_Enemy_Melee_2 is Initiative 3
                            Unit _Player_Scout is Initiative 1
                            Unit _Player_mage is Initiative 0




                            Originally posted by Monokkel View Post
                            Hex grids are a bit more complicated since it varies depending on if you are on an odd or even row. Are you using a hexagonal grid?
                            Yes. It is hexagonal.

                            Comment


                              Originally posted by Mewbits View Post
                              Yes, all I do is grab from the initiative order to place widgets into my UI.

                              After running a for loop with appended object name to the initiative (index) number, this is what it prints out:

                              Unit _Player_Warrior is Initiative 8
                              Unit _Player_Skirmisher is Initiative 7
                              Unit _Player_AOE is Initiative 6
                              Unit _Enemy_Ranged is Initiative 5
                              Unit _Enemy_Ranged_2 is Initiative 4
                              Unit_Enemy_Melee is Initiative 3
                              Unit_Enemy_Melee_2 is Initiative 3
                              Unit _Player_Scout is Initiative 1
                              Unit _Player_mage is Initiative 0
                              Ok, so it seems it is ordered that way from the start. What are the values of the initiative attributes of your units? If you want to have factions acting separately no unit of one faction should have initiative values overlapping the range of initiative values in the other faction.

                              Originally posted by Mewbits View Post
                              Yes. It is hexagonal.
                              Ok, that is no problem. I just remembered that I added functions for getting tiles in all directions in the last update. Check out the Get Adjacent Indexes function in BP_GridManager to see how it works.
                              Advanced Turn Based Tile Toolkit (Marketplace - Support)

                              Dungeon Crawler Toolkit (Marketplace - Support)

                              Discord

                              Comment


                                Originally posted by Monokkel View Post
                                Ok, so it seems it is ordered that way from the start. What are the values of the initiative attributes of your units? If you want to have factions acting separately no unit of one faction should have initiative values overlapping the range of initiative values in the other faction.
                                You're right! It was caused by my child blueprints resetting attributes. The enemy units were more noticeable because they changed from enemy to player units, etc. but the player units went unnoticed because for the most part, they behaved normally. Somehow I changed some of them back to one, but had missed others.



                                Originally posted by Monokkel View Post
                                Ok, that is no problem. I just remembered that I added functions for getting tiles in all directions in the last update. Check out the Get Adjacent Indexes function in BP_GridManager to see how it works.
                                Okay so I tried getting index 1 (east) from the array to use its index in the remove adjacent walls function. But it doesn't seem to be working. (I have tried both with and without the make tile passable functions, same result)

                                Here are some images:

                                Click image for larger version

Name:	grid.jpg
Views:	1
Size:	60.9 KB
ID:	1120830Click image for larger version

Name:	code.jpg
Views:	1
Size:	460.9 KB
ID:	1120831

                                EDIT: I tried offsetting the location's x value -100 instead of 100 so that it was actually the tile's east side, and now it just blocks the tile in front instead....

                                The Mesh is set to ignore all collision channels, and the blue wall will be hidden in game and ignores all collision channels except RangeTrace.

                                EDIT2: I discovered that the edge costs were all set to 99... but they should have been set to 1 when I made tile passable...
                                I changed them to 1 and unplugged the make tile passable function, and now I can just walk right through the wall after setting the two adjacent edges...

                                EDIT3: I also tried adding the edge both ways with a cost of 99, but that didn't seem to work either. Is it perhaps because it is done in the construction script?
                                Last edited by Mewbits; 01-02-2017, 03:38 PM.

                                Comment

                                Working...
                                X