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
    I'm not entirely sure what is it you are trying to do. So the each side gets to move one unit at a turn but they only get to choose the which unit to move at the first turn? Perhaps you can elaborate more about what do you mean by "game has pre-selected which unit will move that turn".

    If you have modify the code. It should be fairly easy to tell if it works specifically for the turn system you want to do. Just put a few unit down and try it. However I think by changing line257 to always true, you have just enable the player to move a unit in FactionUnitPerTurn mode, not ending a turn but go on to select another unit to make further move.
     
  2. govnik

    govnik

    Joined:
    Jun 30, 2016
    Posts:
    5
    Basically what I am trying to do is eliminate turn order (Move Order of units). Even in free it seems that it's just free to set up the turn order, but then the order is set. One unit per turn, no move order is what I want to use.

    Also APRegen per Turn, if you set that to 1 for example that is 1 Regenerates every time the turn order cycles back to that unit. Is there somewhere I could change that to every turn? Like move one unit and attack, turn is over and pass turn. They take their turn, pass back. Then the APRegen happens? (Maybe if Move Order is removed this is fixed as a result too?)

    Context: I set units I want to be able to move every few turns at AP max of 2 with a APRegen of 1 per turn. So 2/2 AP, use attack which cost 2 AP have 0 AP. Begin next single unit per turn turn (with no move order) and regenerate AP so it's now 1/2 AP, so I have to use a different unit for that turn. Next turn the original unit restores 1 AP and is now 2/2 and can work again.

    Another thing I am interested in involves ranged attacks. With ranged attacks (>1 tile) is there a way to make it so if there is a unit in the way, that unit is hit instead of the intended target (like the unit in the way intercepts the attack or simply removes the other target as a tile that is able to be targeted during the declare attack phase)?

    Example:
    [ S ] [ _ ] [ _ ] [ B ] [ _ ] [ T ]

    If that is the board and SBT are units and S is shooter, B is a unit in the target path and T is the Target, currently S can hit T. Is there a way the B acts as an obstacle of sorts? Is there a way to have it act as an obstacle only for the normal attacks and not abilities (preferred)
     
    Last edited: Sep 25, 2016
  3. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    For your first point, I believe there's some bug with the Free move order right now when you are using FactionUnitPerTurn mode. That's why the setting you are using is not doing what you are expected it to do. I'll have that fixed. If you can email me I can send the fix to you so you don't have to wait until I'm doing my next update.

    As for your second point, you can check the RequireLOStoAttack option on the unit so that they can't fire pass an obstacle. To make it so that they can't fire pass a unit, you will first need to add collider on the unit, and then modify the InLOS() function in TBTK_Class_FogOfWar.cs to include the unit layer in the mask, like so:

    LayerMask mask=1<<TBTK.GetLayerObstacleFullCover() | 1<<LayerManager.GetLayerUnit();

    However this will require you to set the collider correctly in accordance to the grid size to get it to work. If you want to make it a step further and have the unit in the firing line to intercept the attack. This is require a considerable lot more work. Basically you will need to perform the same raycast to detect if there's any unit in the firing line and if so, switch the target to the said unit. That said, this can get complicated. You will have to figure out what to do if the attack is not entirely blocked, or there are two units that are in the way, both obscure the attack by equal amount, etc.
     
  4. Zusero100

    Zusero100

    Joined:
    Jan 21, 2015
    Posts:
    1
    Hey I keep trying to create a spawn area or anything with the grid editor but i cant do anything of the sorts? i keep clicking a grid, no luck!
     
  5. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
  6. Frogames

    Frogames

    Joined:
    Jun 10, 2005
    Posts:
    199
    Finally, after 2 years of work, my Unity/TBTK game is out. Thank you @songtan for your great product!
    For those of you who hesitate, the TurnBased-Toolkit is a very flexible and solid product, and a great time saver. It's perfect for indie developers whith great ambitions.


    More infos:

    Farabel is a turn-based strategy game where you start at the end of the story. The game is available for Windows, macOS X and Linux, on Steam, itch.io and Humble Store.

    Steam: http://store.steampowered.com/app/364200

     
  7. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Congratulation! I'm well aware of your release by the way. And I'm very happy for you. The game looks great! I'll pick it up when I have time on my hand. All the best to you!
     
  8. ponasoft

    ponasoft

    Joined:
    Oct 6, 2013
    Posts:
    42
    Congratulations. UI is extremely beautiful. i will play more when i have time and give more feedbacks.


    By the way, did anyone tried tvtk with unity 5.4.2? i just started updating and i hope its compatible with latest version.
     
  9. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I haven't test it myself but I don't see any reason why TBTK is not compatible with the latest version of unity. But do let me know if you bump into any problem. :)
     
  10. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Launched my second game last week ... Demon's Rise 2 - Lords of Chaos. It's built on a very early version of TBTK that is heavily modified to make it into an RPG.

    Pocket Tactic Pics by Rajpreet Dhillon, on Flickr

    iPad Screen 4 by Rajpreet Dhillon, on Flickr

    Feral Ogre Select Screen by Rajpreet Dhillon, on Flickr

    Here's a detailed review from Pocket Tactics:

    http://www.pockettactics.com/reviews/review-demons-rise-2-lords-of-chaos/

    Here's a link to the game on the App Store:

    https://itunes.apple.com/us/app/demons-rise-2-lords-of-chaos/id1153028211?mt=8

    Working on the Android port. Having trouble with OBB files but I don't think that's anything to do with this kit.
     
    Frogames likes this.
  11. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Songtan,

    I'm working on my next game based on this kit and I have a question on Fog of War / Line of Sight. I understand that if I have several full cover tiles in a row, they block line of sight to a unit immediately behind those tiles. However, I find that the units in the tiles further behind those full cover tiles are visible. Is that intended? I would think that if cover blocks line of sight to a unit standing next to it, it would also block line of sight to units further behind the cover in the same direction.

    I'm trying to make my next game set in the corridors of a space ship and I really need to have line of sight blocked by corridor walls completely and not just hide the unit standing immediately next to the cover section. I'm using tiles that are full cover to represent the corridor walls / sections. Is that the right approach or should I be using Walls instead of Cover Tiles?
     
  12. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Once again, impressive work with Demon's Rise. Please let me know when the Android version is out.

    As for the fog-of-war and line-of-sight, if I remember correct, If a row of wall/obstacles block a section of the grid, everything beyond that would be hidden. What you described could very well be a bug. Do you have an example screen shot of that? What version of TBTK are you using?

    As far as fog-of-war and line-of-sight of sight are concerned, wall and obstacle are the same thing. However there's a difference between full wall/obstacles and half wall/obstacles. Half wall/obstacles will not block any line-of-sight, so they are not a factor when it comes to fog-of-war.
     
  13. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    Hi songtan!
    I would like to ask you how to do to insert between scenes a scene to buy new units.
    Like:
    SceneA -----> MarketScene -----> SceneB ------> MarketScene -----> SceneC-----> etc ..

    Thanks!
     
  14. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You can refer to the 'campaign' setup int he demo. It does exactly that, except that it keeps loading back into the same battle scene. To change that, you just need to tell the game to not load into the same scene but the next battle scene. The code is in DemoCampaign.cs StartBattle(). Instead of LoadLevel("DemoCampaignBattle"), you replace "DemoCampaignBattle" with a value that you can configure using UI or a value that you retrieve from your game level manager.
     
  15. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Hey Songtan. Yes it was a bug on my end. For some reason, I had disabled the colliders on the obstacles.

    If I wanted to make unita block line of sight the same way an obstacle tile does, how would I do that?

    Also, any tips on how to implement an ability that moves a unit to a target tile? I dont want to do a teleport but more of a charge ability where the unit moves in a straight line to a target tile that is within a line target area and does damage to all units in that path.
     
  16. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The same way an obstacle does of course. The code is in Fog-of-War class. You can add the unit layer to the layer-mask so that the unit is treated as an obstacle.

    The tricky bit is to determine which tile is in the way. I hope in your case the unit can only travel in the direction of an adjacent tile (in the angle of 0, 60, 120, 180 and so on) instead of any tile in range. If it's the former, you can simply trace a straight-line from the adjacent tile, by tracing the neighboring tile and check the angle. I'm sure some where in the code there's a utility function that determine the angle of a tile from another. If you are using recent version, look for GetNeighbourInDir() in TBTK_Class_Grid. Otherwise your best bet would be to do some kind of sphere cast, which will probably require some re-configuring of collider. You can imagine that would get messy and prone to break other things. Hope this help.
     
  17. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    @songtan
    how can I do that? I have to enter in the "DemoCampaignMenu" scene an empty object with attacked Game Control script?
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    First, do you understand the concept of loading scene using SceneManager.LoadScene? So you use that function to load into any scene you want. You need to have a system setup that everytime a battle is complete, you load into the market scene. That can be done using the next scene variable in GameControl. Then in your own script in market scene, you need to determine which battle scene to load.

    Once that's done, the remaining thing to do is to get the unit you bought in market scene to deploy in the next battle scene you load. That can be done using TBTK data class. You can refer to DemoCampaign.cs and the documentation for this.

    What I meant in my earlier post is all this has been done in the example campaign setup. The difference there is it keeps loading back to the same battle scene. You will need to modify that so that it loads into the battle scene you want.
     
  19. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    Ok, maybe i've understanded that... but what I have to write to replace
    LoadLevel("DemoCampaignBattle"); function?
    I' have tried to replace that with GameControl.LoadNextScene(). I copied from the UIGameOverMenu.cs , and i've putted an empty object in the MarketScene with the GameControl script attached but is not working.
     
  20. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    What should I do?
    Thanks for responding
     
  21. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You don't need GameControl at all. Just replace DemoCampaignBattle with the name of the scene you want to load. Here's the thing. It's not as simple as that. Since you want to load into a different scene everytime, you need a system that keep tracks of player progress and let you know which battle scene you should load next. That is something that is specific to your game, not something that I can help with without knowing any detail.
     
  22. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    The game is simply made on your Demo and uses its scripts, in particular of DemoCampaign. The only thing different is that:
    your DemoCampaign load always a single map, in my game I want to load a sequences of maps alternated by the "MarketScene" (in your demo is the "DemoCampaignMenu" scene). I have deactivated perks for now but the rest is the same of your Demo.
     
  23. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    So the of maps you want to load, and the sequence you want to load them, and any additional condition. Those are the thing specific to your game. I cant tell you anything specific if I don't know them. I can only tell you where is the code to load a battle scene. It's up to you to switch that to the load the scene based on your game.
     
  24. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    Ok. Thank you anyway. I thought it was simple doing that!
    One last thing, if I create different MarketSenes, each one with its own script with the Loadlevel(.... ) function,
    do you think it will work?

    SceneA -----> MarketSceneA [Loadlevel(B)] -----> SceneB ------> MarketSceneB [Loadlevel(C)]-----> SceneC-----> etc ..

    It solve the problem?
     
  25. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Sure. It would be a bit tedious to manage but yes it will work.
     
  26. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    ok. having no alternative will do so. Thanks Songtan
     
  27. Count-Swagula

    Count-Swagula

    Joined:
    Feb 2, 2014
    Posts:
    9
    Hey songtan I really like your asset. I am trying to animate my first unit and my question is two-fold. I wanted to know if there was an optimal way to make a melee character. Are my unit settings correct for this? He was shooting a projectile in melee range at first but then I made an invisible shootobject with the "effect" setting turned on so the little ball projectile doesnt show anymore.

    Secondly, I have not been able to get animations to work. The only time it showed animations is when it had its own animation controller attached but it just ran through the list of animations until death when the scene started (That is how it is set up). When I used your Unit Animator (attached to the mesh) and assigned the clips into the Unit Animation script nothing happens. The animation list also does not show in the Unit Editor as described in the PDF.
    screenshot1.png screenshot2.png


    I looked at the PDF and followed the instructions but am still having issues.

    UPDATE: Got it to work by placing Unit Animation back on the prefab BUT changing root object to the mesh and not the prefab. The animations themselves seem to trigger too late but I would wager that has to do with the animations themselves since I just got this from the asset store to prototype.
     
    Last edited: Nov 22, 2016
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Glad you got the animation working. Yes, you use an invisible 'effect' shoot object for melee attack. If you are refering to the attack animation for delay, you can adjust the value of AttackDelay on the UnitAnimation component to give it some delay. That means the attack only hit after the delay, giving the animation time to play.
     
  29. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Hi Songtan,

    I've run into a bug that I think is in the core code and not something that I have changed. I realized that if I use an ability to change a target enemy's faction, the unit does switch sides. However, if that unit has an ability that either targets Hostiles / Friendlies (not All Units) OR uses an ability that users a shoot object, then the ability does not have any impact on the target. There is no error in the console, it just does nothing.

    So for example, I have an enemy A that has an ability that does 5 damage to Hostiles and uses a Shoot Object. If unit B uses his ability to switch enemy A to his faction, then the player selects enemy A has has it use his damage ability to another enemy C, no damage is done.

    If I remove the shoot object but keep it as targeting Hostiles, then the ability works. Also, if I keep the shoot object but change the target type to All Units, the ability also works.

    Any thoughts? I'm certain I haven't changed the code in this area so it probably exists in your version too.
     
  30. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Unfortunately I no longer have a copy of the old code. If I remember correctly, ability is assigned with the casting unit faction unit ID so that they can identify between friendly and hostile. My guess is when the unit side is switched, the base faction ID which is passed to the ability is not switched. So it's downs to how the code for the unit switching side is done and connects it to ability.
     
  31. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Cool ... i'll take a look and update the switchfaction function accordongly.
     
  32. Count-Swagula

    Count-Swagula

    Joined:
    Feb 2, 2014
    Posts:
    9
    One more thing

    Is there a way to put in talent trees for specific units via the perk system?
     
  33. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Short answer yes. The perk system allow you to modify stats of a specific unit, add ability to a specific unit and modify a specific unit ability. So if you make a series of these perks to upgrade a unit, you can setup their prereq in such a way that they form a talent tree.
     
  34. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Hi Songtan,

    Any tips on how I could restrict target tiles for abilities to be only those within range and within line of sight to the user? I'm working on my corridor / sci-fi version and I'd like to stop players from throwing grenades and things through walls by limiting the target point to somewhere they can see.

    Also, Demon's Rise 2 got a review from Touch Arcade and received 4.5 / 5 stars!

    http://toucharcade.com/2016/11/18/demons-rise-2-lords-of-chaos-review/
     
  35. Count-Swagula

    Count-Swagula

    Joined:
    Feb 2, 2014
    Posts:
    9
    Does anyone know why the UI frame remains when nobody is selected? Is this a bug on my end? UI.png
     
  36. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    @Rajmahal , The potential target tiles that are hightlighted during the activation phase of an ability is determined in GridManager when an ability is activated. Look for something like AbilityTargetSelectMode(). What you need to do is add in LOS check when determining available tile.

    @Count-Swagula, It's not a bug. The frame is set to be visible at all time.
     
  37. Count-Swagula

    Count-Swagula

    Joined:
    Feb 2, 2014
    Posts:
    9

    Oh ok. I there a setting to safely turn it off when nothing is selected? If not can I go into the script ?
     
  38. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid you will have to modify the script to do that. It shouldn't be too difficult. You just need to deactivate the parent object that hold all the UI element when there's no selected unit and activate it if otherwise. The code you are looking for is _UpdateDisplay() in UISelectedUnitInfo.cs.
     
  39. Ultramyth

    Ultramyth

    Joined:
    Dec 21, 2013
    Posts:
    3
    Hi @songtan.

    I found a bug with the counterattack feature. If unit X is currently attacking unit Y, and the counterattack of unit Y destroys unit X, the game hangs. This is with cinematic cameras, if that makes a difference.

    Also, is there any way to have multiple turrets on a unit, or slave additional turrets to rotate in the same direction as a main turret? I have a battleship-like game that I am developing. The units are ships with multiple turrets. I have successfully gotten multiple weapons to fire with ShootPoint nodes, but only the ShootPoint assigned by the TurretObject will actually rotate.
     
  40. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for letting me know about the bug. I'll look into it. Please send me an email if you like a fix in advance of next update.

    As for the turret, I'm afraid there's no way to have multiple functioning turrets on a single unit. Not without making some changes to the code anyway.
     
  41. Ultramyth

    Ultramyth

    Joined:
    Dec 21, 2013
    Posts:
    3
    Cool about the bug. I may email you about the code if you find a fix, @songtan.

    As for multiple turrets, is this a feature that could be implemented (or commissioned if one was so inclined to pay) in the future?

    What about if each turret on the ship was a unit? Is there a way to make multiple units move in a group?
     
  42. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I could possible try to implement multiple turrets for unit. It could possibly take an hour or two to get it right. Please send me an email if you wish to discuss this matter further.

    The alternative tho, is a lot more complicated. I take it you mean the ship itself is a unit but the turret have their own individual hit-point. Otherwise I don't see how that would work. Either way, I don't have immediate solution to this. It's going to take some experiments and it's certainly considerably longer to do than the first option.
     
  43. Ultramyth

    Ultramyth

    Joined:
    Dec 21, 2013
    Posts:
    3
    Thanks, I sent you a mail.
     
  44. ponasoft

    ponasoft

    Joined:
    Oct 6, 2013
    Posts:
    42
    i will ask same question again. is it safe to switch latest unity version?
     
  45. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Honestly I haven't try it myself but It should be. I don't see any new change in new unity that would break the current version.
     
  46. MaestroGames

    MaestroGames

    Joined:
    Jul 5, 2012
    Posts:
    16
    Is there a reason the enemy's health bar and icon do not appear even if they are set in the unit manager? for example just in a brand new scene, using the tank AI and when its the AI's turn, the health bar and icon remain blank similar to how @Count-Swagula has pictured above when nothing is selected. Is there a way to hook this up if its not already
     
  47. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The health bar for all unit should always be visible. If you are not seeing them, chance are there are setting error that cause the health bar to show up in the wrong position (off the screen). There's also the possibility of you have turn them off accidentally. That can happen if you didn't use the default UI-object or deactivate the control object.

    I suggest you try run one of the demo scene and see if the problem is there. If the health bars are there in the demo scene. My guess is you have some setting error.
     
  48. MaestroGames

    MaestroGames

    Joined:
    Jul 5, 2012
    Posts:
    16
    My health is fine, the issue is the AI, I downloaded the asset by itself into a new project and it still has the issue. In the screenshot here, it is currently the AI's turn and it is moving the tank however there is no health, or icon for the AI player, merely the human player when its their turn and they select an object to move.
     

    Attached Files:

  49. MaestroGames

    MaestroGames

    Joined:
    Jul 5, 2012
    Posts:
    16
    basically is there a way to have the Unit selectedUnit appear for AI since in the current form the AI dont get selected to call the UISelectedUnitInfo
     
  50. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Right I see what you mean. You were referring to the selected unit info on the bottom-left of the screen, not the floating overlay. I'm afraid as it's, it only show the info and hit-point of the selected unit. And AI doesn't 'select' a unit when it's moving it. So you can't have the AI unit hp displayed there, not without some modification to the code anyway. You can try to add this line TBTK.OnUnitSelected(unit); in line113 of AIManager.cs, just after MoveUnitRoutine(). With that, the info of AI unit currently being moved should be displayed as well. I'll do that for the next update.
     
    Last edited: Dec 11, 2016