Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TurnBased-Toolkit (TBTK)

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

  1. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Is there a type of tile that blocks line of sight as well as movement? I've made doors that open / close with a lever that turn a particular tile from walkable to unwalkable. However, I'd like to make it so that units cant see what's behind the door when it's closed (block line of sight). Do one of the standard tile types do that?
     
  2. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    You can use the built in fog of war system to do that. First make sure the door is setup as a obstacle object. When you set it to walkable, make sure the collider on the obstacle is disable as well. Then you can simply call OnCheckFogOfWar on all unit to refresh the fog-of-war.
     
  3. Sikosis

    Sikosis

    Joined:
    Jul 7, 2014
    Posts:
    7
    Whenever I select the GameControl object, my console log fills up with 999+ warnings and causes Unity to throttle at 100% CPU. If I select another object, it's all good.

    Error is:-

    Unable to find style '' in skin 'LightSkin' Repaint
    UnityEngine.GUIStyle:eek:p_Implicit(String)
    GameControlEditor:OnInspectorGUI() (at Assets/TBTK/TBTK (Base)/Scripts/C#/Editor/GameControlEditor.cs:368)
    UnityEditor.DockArea:OnGUI()

    I'd love to be able to fix this as it makes it very hard to set game wide settings.
     
  4. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    You must be using Unity4.6. Please email me so I can send you a fix.
     
  5. Windfeld1980

    Windfeld1980

    Joined:
    Apr 28, 2013
    Posts:
    5
    Hi Songtan!

    I own two of your products now and I really love your mentality of having an easy workflow to create rapid prototypes and, hopefully, a finished product :) Great work and keep it coming!

    I've been playing quite a lot with your TBTk toolset, but there are a few things I either can't find or wanted to ask you about for this kit:

    1. Diagonals: In your post #249, you talked about diagonals etc that would smooth out pathing for square tiles. Any news on that? Seen xcom example here if I am making no sense :D

    2. Unit inventory: In the same post, there is mention of a unit inventory - I couldn't find it in the files, but I can see you made it for your own game. (which looks cool, nicely done!)

    3. Unit facing: Is there any variables that could be used for a unit's direction? For example, flanking/getting hit on the side or back would have a crit modifier? Maybe based on armor type?

    4. Fog of war visualization: Is there a way to add/disable tiles based on the fog of war? For example, so you can get a sense of shade in the areas not visible to your units?

    5. Unit/Perk fog of war override: Speaking of fog of war, could there be an ability that could reveal (temporarily) the enemies nearby? Like infrared etc?

    6. Cover lean: This is probably way out of scope, but is there a way to determine if a unit is aiming at an enemy to the right or left a of, for example, a wall? In this way, add a lean animation to imply they are using the cover (yes, this too from xcom :))

    7. Non-blocking walls: For example, a doorway :) I had to fix this by having a left and right side walls that extruded the frame and met halfway.

    Have a great Sunday and looking forward to hearing from you!

    Sincerely,
    Windfeld

    (... I have about a handful more, but I'll spare you some of my wish thinking ... for now! Muahaha! (evil laughter fades away ...))
     
  6. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Hi Windfeld,

    Thanks for your support. I'm glad you enjoy your purchase.

    Before I answer your question, let me say up front that I'm now in the process of updating and overhauling all my package for Unity4.6. Currently I'm working on TDTK. After that I'll start on TBTK. For TDTK I've rebuild everything from ground up. I dont think I'll do the same for TBTK but I'll revise most of the component, make changes and add stuff where it's appopriate. Not saying that that might cover some of the stuff you are looking for but they might. :)

    Now to answer your question:

    1. Unfortunately I havent got to that yet. I'll see what I can do in the coming update.

    2. There are no unit inventory in TBTK. I've explained the reason in the post you refer to. It's tricky to do a inventory system that is open and flexible for customization. At least I havent got any solution that I'm satisfied with. I might give it some thought but dont put too much hope into it.

    3. There's not unit facing in TBTK for now. But I'll try to add that in the next update.

    4. I'll add that in coming update.

    5. Again, I'll add that in the coming update.

    6. The mechanic supports that but unfrotunately you would have to build your own animation solution. The way I see it, It's just not possible to support that due to the nature of how animation works combining with several other factor like gridsize, unit size, cover height/width, etc. There's no readily available way to determine if the unit is leaning towards the right or left. But it's not too difficult to modify the code a bit to get that information. The function used to check if a unit is in LOS performs 3 raycast (left, right, center). So you can find out which side of the unit is exposed.

    7. I dont get it. The purpose of a wall is to block movement and LOS, right? A door way wouldnt be considered a wall since a unit should be able to see and get through it. Unless you meant low wall where the unit can jump over?
     
  7. Sikosis

    Sikosis

    Joined:
    Jul 7, 2014
    Posts:
    7
    Many thanks for your speedy response and fix for this. Loving using it so far, I'm working on a prototype game first to get the hang of it, before moving over to my main game.

    I have noticed that Counter Attacks do cause damage, but then that damage isn't removed from the player.
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I dont quite understand what you are saying, "damage isn't removed from the player"?
     
  9. Thoreandon

    Thoreandon

    Joined:
    Aug 21, 2014
    Posts:
    37
    Just spotted a small bug in
    UnitTBAnimation.cs
    in the Method
    PlayIdle()
    if (idleAnimation != null && destroyAniClip != null ......

    Must be:
    idleAniClip
     
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Noted, thanks for letting me know. :)
     
  11. W1ntermute

    W1ntermute

    Joined:
    Aug 24, 2014
    Posts:
    9
    Hi! Thank you for a great product!
    Do you have any plans about adding big, multitiles units (which occupies,for example, two hexagons,and have, obviously, pathfinding system according to their sizes)?
     
  12. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    No, it's me who should have thanks for your custom. :)

    To be honest. I ddint have any plans for that. But I'm current reworking the toolkit for Unity4.6. So while I'm on it I'll give it some thought and see if it's possible.
     
  13. battlespace

    battlespace

    Joined:
    Nov 1, 2009
    Posts:
    33
    I just purchased TBTK today and it's a great starting point for me. Has anyone modified it to work with more than one unit per hex? My prototype is a naval game with ships, aircraft and submarines. I would like to have up to three units per hex but still only 1 per level (1 at Submarine Level, 1 at Ship Level and 1 at Air Level) but all using the same grid, which would be visible at Ship level.
     
  14. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I'm not sure if anyone has manage that. It would be quite a task if I'm honest. :)
     
  15. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Anyone have thoughts on best way to incorporate an over-watch ability to attack units that move into another unit's view?
     
  16. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Not sure if it's the best way. What I would do is sample a list of point along the move path of the moving unit at a fixed interval (possible the size of the tile or less). At each those sampled point, cycle through all hostile unit on over-watch to check if any of them are in range/view to attack.
     
  17. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    What I'm currently doing is casting a ray to the currently moving unit and seeing if it hits the unit or something else. That seems to work okay but I need advice on how to make the targeted unit pause long enough for the attack and hit animations then continue.
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    What I would do is do the rayacsting while the unit is on the move. Once you detect any incoming overwatch attack, slow down the move speed to almost pausing (like 0.1 or something). While that, you can do the overwatch attack, with the moveing unit in very slow motion, you should be able to complete any attack/hit animation. After that, simply resume the move speed to normal.
     
  19. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    That sounds like it will work. Thanks!
     
  20. GSC

    GSC

    Joined:
    Oct 15, 2014
    Posts:
    1
    Hi Songtan,

    I just bought the TBTK and want to setup a basic level. However I found a problem when I generate the grid.

    When I clicked New Scene HexGrid menu, a new scene will be created with default grid setting. At this time all the Tiles under the GridManager will have its Neighbours tiles setup correctly. However if I updated the Num of Colum and Num of Row and clicked the Generate Grid button to regenerate all the tiles. All the tiles will lost its neighbour tiles (all tiles has an empty Neighbours array).

    I don't know if it is a bug or I miss something. Please help. Thank.
     
  21. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Thanks for your purchase. :)

    What you found is not a bug. The neighbours will be connected in runtime. That how it should be by default. The pre-connected neighbours when you create a new scene is just something I havent change from the earlier version. It makes no difference so don't worry about it.
     
  22. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    Hi! I just started using your TBTK... But Im having a problem... When it's the players turn... The player units can't move nor attack...
     
  23. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Is any of the movable/attackable tile shows up properly? If they do, have you set the target platform to mobile (iOS or Android)? The tile wont respond to mouse click when you do that.
     
  24. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    Yep! Its the one where you go to build setting and click on Android then press switch platform right?

    And yes... The movable/attackable tile shows up properly... But I have no problems clicking on the buttons...
     
    Last edited: Oct 17, 2014
  25. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Yes, what is your current platform in the build setting? Try set to it stand-alone when testing it in editor. Only set it to Android when you want to do an actual build.

    Alos just to clarify, you can click on the movable/target tile but the unit wont move or attack?
     
  26. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21

    Got it! It seem's I have to use an actual android emulator in order for me to press the tiles... Thanks for the HELP songtan! Much appreciated! Keep up the good awesome work!
     
  27. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Exactly, you can ony used emulator while the target platform is set to Andoird/iOS. Mouse Input will not work.
     
  28. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    How can I force a unit's turn to end with code so it stops moving, doesn't attack, or use abilities? Thanks!
     
  29. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    What exactly do you mean force a unit to end it's turn. Under what circumstances? When it's doing something, or simply prevent player to select it and issue a command? If you just want to end the turn, just call OnEndTurn on GameControl.
     
  30. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    I'm looking to make "trap" tiles that end a unit's movement and prevent any further action once they move on it. Not if they end their turn on that tile but as soon as their movement causes them to move onto it. Any idea how to do that?
     
  31. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    The overwatch system I made works fine except for when the unit gets destroyed, then the whole game stops working, waiting for the destroyed unit to finish a move it will never finish. I thought that perhaps if I could force it's turn to end, it would take care of that issue.OnEndTurn just ends the unit's turn not the whole faction?
     
  32. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    @Rajmahal, you will need to start from modifying MoveRoutine() of UnitTB.cs. In the main loop, the unit will move to one tile in the path then to another. Whenever the unit reach a new tile, you can check for the trap. If a unit hits a trap, you can break the loop. Then you will need to disable all available action. You can do this by set the unit attackRemain and moveRemain to 0. For tha ability tho, you will have to create a custom boolean flag for it. Set it to to true when trapped, and clear it in the next round. Whevern ActiveAbility() is called, check the flag before execute the function. You can refer to the stun flag. When that is set to >0, the unit cant make any move.

    @drewradley, I see. First you need to clear the action queue by calling. If you look at MoveRoutine(), before the function ends ActionComplete() is called. That signal other component an action is finished do further action can be taken. Otherwise the game wont proceed. So you may want to check everytime a unit is destroyed if it's moving and clear the action queue properly. By default calling ActionComplete() will prompt next unit or next turn if the action is complete (see the function for yourself). In your case, you might want to add anther conditon that if the unit is destroyed, just called if(onTurnDepletedE!=null) onTurnDepletedE();
     
  33. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Thanks so much for the detail explanation! Been wracking my brain on this one. There are so many different thigns that look like it ends the turn but all of them caused other problems!
     
  34. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Indeed, I do apologise for the some what messy code. I'm actively working to rebuild and streamline it in TBTK2.
     
  35. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Cool ... thanks. I appreciate the guidance. TBTK2 ... sounds interesting. :)
     
  36. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I'm trying to implement a "wait" button that when clicked will allow a unit with a higher turn priority to wait until later in the round to go. I've figured out some of what goes on but I can't figure out where it actually assigns the units' order. I've looked through the "ArrangeFactionUnitOnTurnPriority" function and put a few debugs in there to see what is going on and thought that the unit with the highest turn priority would either be first or last but it's in the middle of the list.

    Do you have an idea when TBTK2 will be released? Perhaps I'd be better of waiting until you've had a chance to stream line the code to edit them. I can figure out a lot of what's going on, but there always seems to be a step or two that confounds me.

    Edit, oh, I just figures something out. It puts them in Faction order THEN turn priority order. So all the AI units were always on top because they are faction 0. How that helps me get a wait function, I don't know, but I feel I'm on to something.
     
    Last edited: Oct 25, 2014
  37. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    It depends on what TurnMode you are using. There are two set of lists. If you are using UnitPerTurn, all units are stored in allUnits according to the move order. If you are using FactionPerTurn, the units are stored in allUnitList in each faction according to the move order within each faction. Assume that you are using FactionPerTurn, what you can do is shift the order of the allUnitList in the faction, by moving the current unit to the end of the list and select the next unit. So when you move each unit, eventually you will come back to the turn which wait and skip it's turn.

    I'm not sure TBTK2 will be ready let alone released. Thing is it will require Unity4.6, which is still in beta. I dont think I'll be release it until the beta is over. But I could always send you an early copy if you want, when it's done. I think it should take 2-3 weeks for me to get it done to a reasonable level, give or take.
     
  38. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    You're gonna get sick of hearing from me. :)

    When I have a melee unit with a move range of 1 on a hex map, the AI units often go into the same hex to attack so there are two units in there and if one of them gets destroyed or moves, I can't seem to attack the one left behind until it moves out of that hex. Doesn't happen with two or more move range. Or on square gird it seems.
     
  39. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    That is definitely a bug. A unit should never move into a tile occupied by another unit.

    I'll look into it when I have time tomorrow, see if I can replicate the bug and let you know.
     
  40. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    It helps if you make a map with blocks every other tile so there is only one tile for them to walk through. then put a player unit blocking the only way through and let the AI pile up behind that one hex. But just putting one unit in a place where the AI has limited access to will do it as well. In the mean time, I'm just making sure all my units have a move range greater than 1.
     
  41. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I did some quick test. Have to say everything seems to be working correctly for me. I have set all unit to melee, with move and attack range of 1 and limit the grid to a single row of tiles. Perhaps you have break the code accidentally when modifying it?
     
  42. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    This was unmodified version. Whenever I encounter a problem, I test it out in an unmodified version to see if it is my changes or not. I'll check again. I do recall it needed to upgrade the project to a newer version of Unity when I reopened it so perhaps it was a version issue.
     
  43. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Just tried it again on a new install and restart so it updated and it still happened.

    twounitsonehex copy.png

    I can send you the project if you want.
     
  44. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I found out what's wrong. Change line1669 of GridManager.cs to:

    if(tileNeighbours.walkable && tileNeighbours.unit==null) list.Add(tileNeighbours);


    That should fix the problem.
     
  45. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    do you mean if(tileNeighbours[i].walkable && tileNeighbours[ i ].unit==null) list.Add(tileNeighbours); ?

    edit: The brackets kept disappearing on me so I guess they probably did for you as well.
     
  46. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Yes, you are right. Sorry about that.
     
  47. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Thanks for the fix! I hoped it was something simple!
     
  48. Thoreandon

    Thoreandon

    Joined:
    Aug 21, 2014
    Posts:
    37
    Is it possible to have a space between tiles ?
    I have to set all tiles that have walls or doors on them to unwalkable or otherwise the characters would stand too close and props would reach into the walls.
    It would be better if i could place walls on a space between tiles.

    Edit:
    GridToTileSizeRatio should do the trick :)
     
    Last edited: Oct 28, 2014
  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Yes, you can play with the value of gridToTileSizeRatio to get the spacing you want. Something like 1.1 should do nicely.
     
  50. Thoreandon

    Thoreandon

    Joined:
    Aug 21, 2014
    Posts:
    37
    I noticed one problem: In the Editor, the tiles are larger than in the game. This makes it hard to layout everything correctly. Perhaps you can figure it out, i've had a grid of 1.4 and a ratio of 1.25, but it actually does not matter, its always different.