Search Unity

TurnBased-Toolkit (TBTK)

Discussion in 'Assets and Asset Store' started by Song_Tan, Aug 11, 2013.

  1. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Can you elaborate how it got stuck? It's hard to give you a specific answer. There are so many way the AI can be modified if you want to change its behaviour in a certain way.
     
  2. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    upload_2020-4-5_14-17-57.png

    The 2 pink units above the unwalkable nodes will not walk around gap, they will just stay there until I move around to their side.

    Also I added an extra question to my previous post.. just as you replied :)
     
  3. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Well the current AI algorithm is a bit conservative when trying to get to hostile. They only do a search within their movable nodes. So they don't really work if you have a huge obstacle where they really need to go the long way round. The solution to this obviously is to try have them to follow a direct path straight to the nearest target. The problem with that is when doing that they tend do ignore cover so I have chosen not to do that. But I suppose if you are not using cover system then it's not a problem. I can try do add that when I find time. You can wait if you don't mind, or you can try doing that yourself.
     
  4. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    I think the AI code is a beyond me atm, so will happily wait.

    Any ideas with the other question?
     
  5. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Sorry I wasn't aware that the edit part was a question. You can stop the cursor from highlighting the node changing line40 of UIInput.cs to following:

    if(node!=null && node.walkable && !node.HasObstacle()) GridIndicator.SetCursor(node);
     
    Stexe and Liberation85 like this.
  6. Stexe

    Stexe

    Joined:
    Feb 2, 2014
    Posts:
    217
    Weird, this thread was down yesterday. Unity being weird again.
     
  7. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    @songtan Hi, discovered a bug in the new version.

    De-selecting End Move After Attack in the GameControl is causing a hard crash when an AI unit fires at another unit in a neighbouring hex. With 1 or more hex distance between the units, the crash does not occur.

    This is with fresh projects, however I am using 2019.2.8f1.
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for letting me know. I'll look into it.
     
  9. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    Hey again Songtan, found another bug.

    With fog of war enabled, when the AI is taking its turn it crashes game/unity when activating any hidden units.
     
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Duly noted. I'll try to get all this fixed and release an update over the weekend.
     
    Liberation85 likes this.
  11. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    Upon further research, I found that it is not the fog of war causing the issue, it is more down to unit sight range. I've had to give all my units (on both factions, although probably only need for the AI) a sight range of 100 to stop the game crashing.
     
  12. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It's a problem with the existing AI code when they are trying to locate hostile unit when there's none in range. I've been working on the issue we talked about earlier this week and might have accidentally fixed it with the new code.
     
  13. sisko89

    sisko89

    Joined:
    Mar 8, 2019
    Posts:
    20
    Hi Songtan,

    1) I'm trying to use the damage preview tooltip, but on abilities (instead of normal attacks).

    I got it working correctly for single target abilities using the UITooltip.ShowAttackInfo function inside of ShowTooltipNPreview, but that works only for the selected node.

    Now I'm trying to display multiple tooltips for AOE abilities, one tooltip for each unit inside the AOE. (ej: if I'm casting a fireball on two enemies at once, I'd like to see the preview of how much damage it will do to each unit individually).
    But I can't figure out how to trigger ShowTooltipNPreview for ALL the tiles of the AOE, not just the one in the center.
    Any advice for this? Sorry if I'm asking too much, I know this is not supported by default but hopefuly its easy to answer.

    2) Any tips on how to apply the updates you make to the asset, without overwritting all the scripts (which are already heavily customized)? So far I've been using code comparission between the latest version and the previous one and then applying the code differences myself. It works but I feel there must be a simpler way... Do you use git or any version control?

    3) The latest update works great, AI now uses all available action points! But a minor bug: If the AI can attack twice without moving, it will trigger both attacks almost simultaneosly, instead of waiting for the first attack animation to finish. Not a problem for myself but I'm reporting it just in case.

    Thanks a lot!
     
  14. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    1. The easiest way I can think of is having ShowAttackInfo() taking a list of attack instance instead of a single instance. Obviously you will need to have multiple popup tooltip object for UITooltip, one for each attack instance in the list. I recon this is fairly straight-forward to do. You just need to have duplicate the popup object in UItooltip (maybe make a list?), and make a loop in ShowAttackInfo() that iterate through the list of attack instance being passed. Hope this make sense.

    2. Well I'm sorry to say that I don't use git or any version control. If it helps I don't always modify every file in every update. You can use the importer to check which script has been modified. Just in case you are not aware of this.

    3. Thanks for letting me know.
     
  15. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    The new update seems pretty good songtan. The previous bugs are fixed and the AI is a lot better.

    Did notice that when having units toggled to pass through other units an issue did arise. When a unit passes through another unit, the actual unit that got passed through is not selectable afterwards.
     
  16. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I see. Thanks for letting me know.
     
  17. nlv22

    nlv22

    Joined:
    Dec 20, 2016
    Posts:
    31
    Hello,

    I seem to have an issue with Unit's move animation. The Unit first moves then after they made it to their final destination, it plays the move animation - then it stops after a couple of seconds and reverts back to idle.
    • I am using the UnitController that came with the project with an Avatar. I tried switching the exit times but it did not do anything.
    • I also tried to make my animation controller or use the Animation Component but I couldnt get any animation to work at all.
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    First, you have to use the 'UnitAnimator' controller in 'TBTK/Animation' in order for the animation to work. The script sent specific command to the animator that only that particular controller would respond to.

    Anyway it's very tricky for me to tell what is wrong without any visual or log. Maybe you can send the model and the animations so I can have a look?
     
  19. nlv22

    nlv22

    Joined:
    Dec 20, 2016
    Posts:
    31
    Thanks! I sent a message to you with the files.
     
  20. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    @songtan What is the AI version of GetSelectedUnit();

    I have a script that flips sprites due to the transform, however with player units it works fine but the AI does not seem to use GetSelectedUnit.

    How can I check if a AI unit is active?

    Edit: I found AI.ActionInProgress can be used.
     
    Last edited: Apr 25, 2020
    Stexe likes this.
  21. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    Hey again @songtan another quick question.

    What is the best way to get the position of a unit that is being targeted for attack?
     
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    What's the context here? If you have reference to the target unit instance (like in AttackRoutine or AttackInstance), you simply get the transform position of the target unit instance. If you are trying to access that outside the code of the attack sequence, you will have to do it the other way round. Meaning adding code to the sequence to broadcast that information. Like using an event delegate for instance.
     
    Last edited: Apr 27, 2020
  23. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    Thanks for the nudge in the right direction! I am trying to access it from outside, so found I could get a vector3 out of targetNode.unit.GetPos() and return the x axis in another script. Feeling a bit daft, should have spotted that :)
     
  24. ScuffedStudios

    ScuffedStudios

    Joined:
    Jun 2, 2016
    Posts:
    5
    @songtan How would I go about adding new hex node types (like unwalkable, deployment, wall, etc)? Also, how do you change the hex texture to allow custom art instead of the brown color they start as?
     
  25. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The 'node type' that you mentioned falls into two category. One is a prefab, an object placed on the grid like wall and obstacle. You can add more (or replace the default one) by assigning the new prefab in GridGenerator, a component on the game-object 'GRID_MANGER_GENERATOR' in the scene. Just expand the default editor and you see. The second category like deployment and walkable are just indicators for the state of the node. You can only replace existing one. They are assigned in 'GridIndicators' in the scene.
     
    Stexe likes this.
  26. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    @songtan Did you come up with a fix for the "toggled to pass through other units" bug? As I would like to use that feature.
     
  27. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Yes. I believe I have.
     
  28. GenEmm

    GenEmm

    Joined:
    Mar 22, 2013
    Posts:
    8
    Hi everyone,

    Great day! One of the TBTK features is this: "Flexible game logic that support customization on many aspect of the game rules, turn/round logic, unit movement/attack rules, etc."

    With that in mind, may I know if the TBTK can do this kind of game example? 2 opposing teams with 1 unit each. Turn 1: Movement Phase: Team A goes first by moving and acting its unit but goes back to its original position. Then Team B does the same. Execute Phase: Then both units of Team A and B execute both movements and actions. Then turn 2, Then repeat until 1 team wins. Is this possible with TBTK?
     
  29. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid that is not possible. Although the players take turn to make the move but the actual game played out in real time since there's no clear definition to the order of actions taking place.
     
  30. GenEmm

    GenEmm

    Joined:
    Mar 22, 2013
    Posts:
    8
    I understand but what if the system will be customized wherein:

    0. there will be 4 variables added which are the team1unit_designated_movement, team1unit_designated_action, team2unit_designated_movement, and team2unit_designated_action

    1.1. team1 unit will normally do TBTK's movement and action but after it is done the movement and action will be saved in the custom variables team1unit_designated_movement and team1unit_designated_action then the position of team1 unit will be reset prior the normalTBTK's movement and action

    1.2. do the same to team2 unit but for team2unit_designated_movement and team2unit_designated_action variables then also reset team2 unit position

    2. apply the saved movement and action values of the 4 custom variables in team1unit_designated_movement, team1unit_designated_action, team2unit_designated_movement, and team2unit_designated_action at the same time for both team units

    3. Next turn

    Will it be possible? So it will be like:

    1.1. [Plan] Move, act, save (movement and action), and reset the position of team 1 unit
    1.2. [Plan] #1.1. but for team 2 unit
    2. [Execute] apply saved #1.1. and #1.2.
    3. Next turn
     
    Stexe likes this.
  31. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It's possible but It's not that simple. In a typical turn-based model, there's a natural order for every movement and action taking place. Event-A happen, then event-B, then event-C. That is simply not the case in what you have in mind. For instance, the units move at the same time. What happen when 2 or more units try to move into a same position. What happen a unit is given an attack order but the target has move out of range. You either has to come up with a whole list of rules for cases like this (which is contrived and probably unintuitive to the player), or running the execution phase in real-time (which make the whole thing only turn-based in name). Neither are well suited for what TBTK set out to be.
     
    Stexe likes this.
  32. Tarrasque

    Tarrasque

    Joined:
    Jan 5, 2015
    Posts:
    21
    Hi songtan and others,

    I have been postponing updating TBTK, but now I thought that I should finally make the update to this newest version. So I was using 3.0 f3 and now after importing I started getting errors like this. Any idea how to fix and is is likely that I will get a lot of other errors too?

    Capture.PNG
     
  33. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You've probably missed some files when you are importing the latest version, _TBTK.cs in particular. Have you try import into a empty project?
     
  34. Tarrasque

    Tarrasque

    Joined:
    Jan 5, 2015
    Posts:
    21
    Yes, it is working without errors in empty project. I think I will be able to solve it now, thanks!
     
  35. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    @songtan Bit of a question for you.

    I need a way of updating a Units location node based on the units transform.

    So if in runtime I manual alter a unit's transform to move the unit to a different location, I need a way to update the position Node.
     
  36. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Try this:

    Node newNode=GridManager.GetNode(unit.GetPos(), null);
    unit.node.unit=null;
    unit.node=newNode;
     
    Stexe likes this.
  37. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    I'm adding that into the unit script, however I'm getting:

    The name 'unit' does not exist in the current context.

    I've tried creating a unit gameobject and assigning it thisobj but that does not seem to work out.

    I suspect I'm missing something obvious!
     
  38. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    If you are putting that code in Unit.cs, you have to remove all the "unit.". If you are not, you need declare and assign the unit variable. Anyway, if you plan to put it in Update(), I would advise against that. This should only be called when you have done manually moving the unit.
     
    Stexe likes this.
  39. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    Got it half working. Once the method has been called any unit that has been moved by hand reset their Nodes correctly as intended.

    However I then find that I can only select one unit, the others require me to individually drag and drop the unit from the hierarchy during runtime into the Unit slot before being selectable. Any ideas with that?

    upload_2020-5-19_22-45-16.png
     
  40. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm not sure what are you trying to do here. Is this something you do yourself in editor? Or is this meant for the player? How do you select the unit to move in the first place. If this is something the player can do in runtime, surely there are code for them to select and move the unit. From there you should have the reference to the unit, no? If this is for editing only, you can just change the unit variable to a list so you can assign multiple units.
     
  41. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    It is part of a save system basically.

    I'm saving the unit transform for positioning. Upon loading I set the transform and use "Node new node" code to set the node. This works, all units saved reload in the correct positions it is just that I can only select one unit afterwards the rest are un-selectable.

    upload_2020-5-20_8-53-19.png

    Both the above units are in the saved positions but the left hand unit is not selectable. The only way for that left unit to be selectable is to carry out the procedure in my above post.
     
  42. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Selection of unit is based on node. When the unit is occupying a node, the node will have a reference to the unit (node.unit). Without that the system will recognise the node as empty so although visually the unit is there it's actually not according to the system. What you need to do is use the code on all the unit transform loaded as you are loading them.
     
    Stexe likes this.
  43. Liberation85

    Liberation85

    Joined:
    Apr 16, 2019
    Posts:
    65
    I've got it working

    Node newNode=GridManager.GetNode(unit.GetPos(), null);
    unit.node.unit=null;
    unit.node=newNode;
    node.unit = this;

    Added that bit at the bottom and it works a charm. Thanks for the help :)
     
    Stexe likes this.
  44. testament32

    testament32

    Joined:
    Mar 18, 2020
    Posts:
    1
    Hello there songtan! And the rest of you fine folks
    I was going to read through the entire thread before posting anything that could be answered too easily. But, it seems to be growing quite frequently with new posts, so I figure maybe if I just get into the conversation now, I might save myself the headache of reading through posts about errors that have already been fixed, etc. But I don't want to miss out on all the other cool projects done by the others in the community so far either. Oh well. I did skim the thread and read the first 25 pages or so.

    My point is I want to get involved with the convo and start my game development. So I apologize in advance if I come here with any newbro questions. This is also, IIRC, my first post in the Unity Community as a whole, so it serves as my introduction. Yours is the first asset I've bought and I'm delighted to know of it's existence. It has definitely saved me a ton of production time and it seems like a really solid kit and I'm excited to get working with it.

    Tbh though, I haven't gotten much done on it yet, maybe this is just mental blockage but I feel like if I understood the kit itself better I might have a better time working on my game.

    Either way, if I do have questions, I'll ask, I just wanted to make it known that I've bought the kit and I'm working on a game with it. :) Turnbased Tacticals are practically my favorite game type.

    Oh, I suppose I do have one question. Since the thread is now several years old, have you put in the time to play some of the games which keep getting mentioned? Such as X-COM, Banner Saga, Tactics Ogre, Final Fantasy Tactics or Into the Breach? Just curious, cuz they're awesome, and you owe it to yourself to try some of them :p

    I'll be lurking, good work and good luck to everyone else on their projects :)
     
    Stexe likes this.
  45. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I've finished all the modern XCOM and played a little bit of other tactics game. If only I have more time to go through them all thoroughly. The problem is every time I play something, I feel like I should be spending the time working on my project instead.

    Good luck to your project by the way!
     
    testament32 and Stexe like this.
  46. AndyMul

    AndyMul

    Joined:
    Jul 13, 2013
    Posts:
    41
    Hi Song, sorry if this question has been asked before.. But is there a guide on how to create x number of levels, where our players/characters/units progression can be saved and carried forward through those levels?
     
  47. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There isn't a guide but you can look at the demo scene 'Demo_Persistent_Game' and 'Demo_Persistent_PreGame'. That two scenes is meant to work together with the later serve as a between-level scene. The units are carried over between loading. You probably need to look through the documentation (there's a section named 'Integrating TBTK to your game') for some explanation.

    That said, none of the progress made are saved. You will have to come up with a save system yourself. Hope this help.
     
    Stexe likes this.
  48. Stexe

    Stexe

    Joined:
    Feb 2, 2014
    Posts:
    217
    I've been working with the Persistent Game stuff quite a bit as well as implementing potential save system solutions. It can require a bit of tweaking but it overall works well once you understand the basics.
     
  49. AndyMul

    AndyMul

    Joined:
    Jul 13, 2013
    Posts:
    41
    Thanks for the clarifications, Song Tan :)
     
  50. Aleksander1980

    Aleksander1980

    Joined:
    Nov 2, 2016
    Posts:
    2
    1) How large maps with square tiles can I make so that they run well on modern PC?
    2) Do I understand right that I can edit source code of this asset in unity for my project?