Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

TurnBased-Toolkit (TBTK)

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

  1. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    For the issue with animation, try check/uncheck the 'apply root motion' option on the animator.

    As for the death animation, I've looked at the code and things should be working if you have assigned the death animation correctly. If you want to leave the dead units on the grid, try disable the last line of Dead() in Unit.cs. Doing so will probably fixed the problem with the dead animation too, assuming the problem caused by the code, not the setting error with the animation. You will probably need to modify the AnimatorController to remove the exit transition from the death state.

    Hope all this make sense.
     
  2. Seril

    Seril

    Joined:
    Jan 22, 2018
    Posts:
    1
    Great asset!
    Nothing like this anywhere else. You are the best!
    But there were questions,
    please tell how to:
    1. change the accuracy depending on range
    2. to change the spine of the direction when deploying player units
    3. automatically end turn
    4. generate obstacle at the start
     
  3. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    Thanks.

    1. You have to modify the existing code, specifically TBTK_Class_AttackInstance.cs. In CalculateChance(), you can modify the calculated hit chance however you want based on the range. You can get the distance by using GridManager.GetDistance(srcUnit.tile, tgtUnit.tile);

    2. You can change the deployment direction in FactionManagerEditor (Spawn Direction)

    3. It's not supported by default I'm afraid. It's very tricky to get right given the amount of variables in used. Especially when there are abilities that could be available/unavailable depends on the situation during play.

    4. You can enable 'Generate Grid On Start' in GameControl to have the system regenerate the grid. This way the obstacle will be regenerated as well. However that also means pre-placed item on the grid (units and collectibles) will be reset too. If you want to generate the obstacle while keep everything in place, I'm afraid you will have to modify the code.
     
  4. pbrowne

    pbrowne

    Joined:
    Aug 27, 2018
    Posts:
    57

    Thanks for the prompt and very helpful response Songtan, greatly appreciated!

    Unchecking 'apply root motion' did fix the problem with the mech animations, they are now working very well.

    I commented out the last line in the unit.cs script:

    //public void DisableAnimation(){ unitAnim=null; }

    The unit still disappears from the grid when killed and the death anim does not play.

    tank_death_anim.png

    Looking at the Animator State Machine, I can't see any transitions on the Destroy state:

    Destroy.png
     
  5. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    I didn't meant the last line of Unit.cs. It's the last line of the function Dead() in Unit.cs. It looks like this Destroy(thisObj);

    And very sorry about the animator state. I've just checked and reliazed that there isn't a transition out of the state. So you don't really need to do anything there.
     
  6. ppmpyae7

    ppmpyae7

    Joined:
    Sep 13, 2018
    Posts:
    13
    If you add IAP(in app purchases ) to asset,that would be extremely perfect.Please can you consider about it or any guide to add IAP?
     
  7. ppmpyae7

    ppmpyae7

    Joined:
    Sep 13, 2018
    Posts:
    13
    And a way to multiplayer system?
     
  8. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    There are many ways to implement IAP. It's not possible for me to cover all the possibility. Beside a great deal of IAP is about the app setting, not coding. There's only so much I can do so it's kind of pointless tring to add IAP tbh. If it's a guide you are looking for, there are already quite a lot of them out there. Just google it.

    Regarding network multiplayer, I'm afraid I can't help here. I don't know much about network coding.
     
  9. ppmpyae7

    ppmpyae7

    Joined:
    Sep 13, 2018
    Posts:
    13
    I googled it and they say that I need a ID of the currency I want to sell.That is why I am asking.What is the ID of the currency you created?If there is not,where can I manage thethe ocde of currencycurrency.
     
  10. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    I assume you are talking about the currency for perks? The ID is just an identifier for the IAP to determine the item (be it currency, upgrade, item, content...) in game for a particular transaction. You create them as you create IAP item. There isn't one right now for the perk currency so you can just create one. You can find all the code for perk currency in PerkManager.cs.
     
  11. ppmpyae7

    ppmpyae7

    Joined:
    Sep 13, 2018
    Posts:
    13
    Can I have an android demo?
     
  12. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    I'm sorry. I'm afraid I don't have an android demo readily available.
     
  13. ppmpyae7

    ppmpyae7

    Joined:
    Sep 13, 2018
    Posts:
    13
    Then,just use your asset and finish it.I dont need anything.I only want to test UI and game play and others.No need any otherothers.Just need a basic one.
     
  14. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    Alright, here's a link to the android version of the default demo.
     
  15. ppmpyae7

    ppmpyae7

    Joined:
    Sep 13, 2018
    Posts:
    13
    Hi,can I have your email address to PM you for more questions?
     
  16. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    It's k.songtan@gmail.com. You can find that information in the documentation or the contact info window from the drop down menu. Or you can email me via my website.
     
  17. Tezpaps

    Tezpaps

    Joined:
    Dec 15, 2017
    Posts:
    8
    I just updated to unity 2018.2.17 and when i press generate grid i cannot see the grid. I have noticed that grid painter does not import. is this the problem?
     
  18. Tezpaps

    Tezpaps

    Joined:
    Dec 15, 2017
    Posts:
    8
    There is also no unitTB script
     
  19. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    What do you mean by GridPainter? Are you referring to GridEditor or GridManager?

    I'm pretty sure something is wrong when you don't have unitTB script. The rest of the code wouldn't even compiled without it.
     
  20. Tezpaps

    Tezpaps

    Joined:
    Dec 15, 2017
    Posts:
    8

    I have a script called unit (no TB) ...in one of your videos i saw Grid Painter..maybe its an older version.

    Anyway, i reinstalled and i still don't have these scripts but everything is working. The only issue i have now is that after my units attack and play their animation, they tilt (lean back), do you have any ideas as to why?
     
  21. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    I take it you are using your custom unit? Have you assign a turret-object to your unit? If not, you will probably need to disable the aim-in-x-axis option for the unit. Of course there could be other reason but this is the most probable reason I can think of.
     
  22. ppmpyae7

    ppmpyae7

    Joined:
    Sep 13, 2018
    Posts:
    13
    Hi,how can I create an Id to the perk currency?
     
  23. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    I'm not sure what are you trying to do, but perk currency is just an simple int. It's not a class like ability or perk where you can create variable within it. And I don't see why would you need an id to it since there's only ever one PerkManager and one perk currency.
     
  24. ppmpyae7

    ppmpyae7

    Joined:
    Sep 13, 2018
    Posts:
    13
    I want it for IAP intergration
     
  25. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    In that case, I think what you need is not an ID for the perk currency, but an ID for the IAP item, used to identify when the IAP item. You can just modify the value of perk currency in any event of IAP so there's really no need of it.
     
  26. PatBGames

    PatBGames

    Joined:
    Mar 28, 2009
    Posts:
    119
    Hi, thank you for this great asset :)

    Is it possible without coding to allow a unit to have "2 move" or "1 move followed by 1 attack" in that order only?

    I've tested various settings with or without using AP for move, but never obtained the right result.
     
  27. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    Sorry for the slow respond. You can try to set the units Move-Per-Turn to 2 and then uncheck the EnableActionAfterAttack option in GameControl. That way the unit can take 2 moves but their turn will be up whenever they make an attack.
     
  28. PatBGames

    PatBGames

    Joined:
    Mar 28, 2009
    Posts:
    119
    Thanks for your answer.
    Doing what you write can allows the unit to do 2 moves and 1 attack in the same turn, it's not my goal. But you put me on the right way.

    I've checked use AP for move, use AP for attack, and I've set the units Move-Per-Turn to 2, move AP cost to 1, move range to 3, Attack AP cost to 3, ActionPoint to 6 and then unchecked the EnableActionAfterAttack option in GameControl.

    At last, my unit can do what I wanted:
    - 2 moves (up to 3 tiles each)
    - 1 move (up to 3 tiles) followed by 1 attack
    - 2 moves (up to 3 tiles cumulated) followed by 1 attack (same as previous line)

    Tks :)
     
  29. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    Sorry I'm not aware that you need to be able to attack after making 2 moves. Glad you found a solution. :)
     
  30. PatBGames

    PatBGames

    Joined:
    Mar 28, 2009
    Posts:
    119
    I think I found bugs about effects duration.

    You can easily reproduce it by creating a mission with only 4 "Tank MKIII".
    Use the "Tactical Charge" ability on all 4 tanks, it adds 2 tile to movement range (no matter if you move the tanks or not). And then, end the turn.

    This effect is supposed to apply only during the turn it is activated, but at the start of the next turn, 2 of the 4 tanks will have the ability effect not removed.

    Proposed correction:
    in Assets\TBTK\Scripts\EffectTracker.cs:30
    In _IterateEffectDuration()
    Replace : for(int i = 0; i<unitList.Count; i++) {
    By : for(int i = unitList.Count-1; i>=0; i--) {
    Iterating the list in reverse order prevents items to be missed when the list is modified inside the loop (it occurs to the next unit when an effect ends).

    I thing I've also founded a second bug when investigating this one.
    In Assets\TBTK\Scripts\TurnControl.cs
    In TurnControl._EndTurn(), the function IterateEndTurn() is called after the first available unit was selected. So if the 1st available unit has an effect that has ended this turn, it is selected before the effect was removed. It cause to effect to be visible, but if you hover the description, you have an index fault in console. If you select another unit and come back to the first, the effect is no more visible and all is working well.

    I have corrected this second bug by moving the call to IterateEndTurn() just after "currentTurnID+=1;" in TurnControl._EndTurn(), but I'm not sure if it can have side effects (As far as I've tested, it seems to work well).
     
  31. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    You are absolutely right on both issues. Thanks for your feedback and the suggested fix.

    For the first bug, I would go ahead and do the same for both the tileList and visibleTileList since they work just like the unitList. Unless you are not using any effect and ability that affect tiles that is.
     
  32. OrionDesaul

    OrionDesaul

    Joined:
    Feb 23, 2018
    Posts:
    10
    Hello! can someone explain how to call an ability from code?
     
  33. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    It depends on what ability you want to use and when you want to use it. Unit-ability or faction-ability? Does the ability require a specific target?

    You can look at UIUnitAbilityButton.cs and UIFactionAbilityButton.cs OnAbilityButton() to get an idea and go from there. That is the function being called when the player press the ability button. However that use the ability of the selected unit or faction. And it only works for ability that doesn't require a target. For ability that require a target, you will also need to call targetModeTargetSelected() on GridManager, passing the target tile after you select the ability.
     
  34. tomaz52

    tomaz52

    Joined:
    Feb 12, 2014
    Posts:
    15
    Someone already port Tbtk for multiplayer? If someone did, can sell for me?
     
  35. OrionDesaul

    OrionDesaul

    Joined:
    Feb 23, 2018
    Posts:
    10
    Thanks!!
     
  36. OrionDesaul

    OrionDesaul

    Joined:
    Feb 23, 2018
    Posts:
    10
    SongTan,
    Thank you for pointing me in the right direction on my previous post! I'm really enjoying your asset.
    I have one additional question. what I want to do is : whenever an ability, perk , move or attack (basically any action by the player) is requested , I want to pause the action until the space bar is pressed.

    for example , on the player faction turn, the player selected a square to move into but before the move is executed the player must press the spacebar. I know how to accomplish the waituntil key press via Ienumerator I just can't figure out where, in the all the code, to insert it so that it will cover All the actions. to make sure it only effects players choices I currently use something like:
    if(FactionID ==0){then do stuff}

    I'm sure, to a pro this place in code is probably obvious but I can't seem to find it. Any Suggestions?
     
  37. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    The code you are looking for is OnCursorDown() in GridManager. From there it branch out a bit to OnTile() or the ability target call back function depends on the context.
     
  38. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    26
    EDIT: FOUND THE ANSWER
    But i'll leave below for anybody else who might have the same question

    So each unit has its own unit ID in unit.sc, I had it set to 15 that another unit was using that ID number so moved it to 20, also when editing IDs the Unit Editor in tools will come up blank you just need to either click play or save your project and reopen to 'refresh' the editor


    ……………….…………………………………………………………………….
    Hey Song!
    Thanks very much for the great tools, i'm currently trying to add my first humanoid type unit but seem to be getting stuck. It seems when adding to the faction list it generates a 'clones' of your already existing units.

    I've uploaded all the screens I've updated but unsure if I'm missing anything!

    Thanks in advance! image1.JPG image2.JPG image3.JPG image4.JPG
     
    Last edited: Jan 11, 2019
  39. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    26
    Hey Song!

    I'm wondering if you would be able to help me with the following:

    * Remove delay with attack animation, the attack animation is delayed about 6 seconds (the unit animation script is set to zero '0' I tried adding a negative value but seems to be delayed until after the projectile is shot still? Also is it possible to speed up the rotation of units?

    * Unit is shooting projectiles when none are selected? currently in the unit editor and the unit.sc there are no projectiles selected by still shoots a white dot, can this be removed?

    * If possible to leave destroyed bodies?

    I've attached a video example.



    I hope you don't mind me asking these questions i'm really enjoying the kit! and its amazingly set out!
     
  40. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    I'm glad you like the kit. :)

    The attack delay is not for delay the playing of attack animation. In fact, nothing does that. From the video, it looks like the animation is delayed by the unit trying to get into the correct rotation (facing). For humanoid unit, you definitely should disable the 'rotate in x-axis when aiming' option in UnitEditor. For clarification, what the attack delay do is delaying the shooting of 'shoot-object' to allow you to sync it with the attack animation.

    All attack use 'shoot-object', even melee attack. That's just how the code work. If you don't assigned any shoot-object for a unit. The system will simply create a dummy shoot-object. Which is what you see in your game. What you need to do is use a empty 'effect' type shoot-object for melee attack. Look for SO_Effect_Empty in TBTK/Prefabs/ShootObject/.

    Yes, remove the last line of Dead() in Unit.cs.
     
  41. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    26
    Hey Song thanks for the quick reply!

    All that feedback was really helpful! Ive disabled the rotate in x-axis in the unit editor, ive also sped up the rotate in the unit.sc but stills stuck with a delay.

    I'm not particularly code savvy, is their any way i can trigger the attack clip with the other shoot event?

    Ive attached an example, ive just put some placeholder sounds which seems to trigger as intended.


    Thanks again for everything, once I've got this i should be able to keep dabbling on my own from then on!
     
  42. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    Unfortunately, the attack animation can only be triggered by an attack without digging into the code.
     
  43. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    26
    Yeh no worries!
    There just seems to be something blocking the attack and over-watch animation from triggering instantly, and the times don't seem to be consistent, ranging from 1-2 seconds delay but the audio and the effects are triggered instantly without fail.

    Ive been going through line by line and disabling code to see the effects

    Do you think i'm getting warmer around 838 in unit.sc?

    //play animation
    float animDelay=PlayAttackAnimationNAudio(attInstance.isMelee);
    if(animDelay>0) yield return new WaitForSeconds(animDelay);



    //shoot
    for(int i=0; i<shootPointList.Count; i++){
    Shoot(shootObj, shootPointList, targetUnit.GetTargetT().position, Mathf.Max(0.2f, targetUnit.hitThreshold), this.AttackHitCallback);
    if(delayBetweenShootPoint>0) yield return new WaitForSeconds(delayBetweenShootPoint);
    }


    It seems to be the only logical place where the shoot animation is triggering, thanks again for your help in this!
     
    Last edited: Jan 11, 2019
  44. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    The function to play animation and audio is PlayAttackAnimationNAudio(). As you can see both audio and animation are played at the same time. I suspect the delay you are seeing is due to the transition setting in the animator controller.
     
  45. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    26
    Thanks Song! found the culprit (thinking about your comment earlier with all units, including melee needed to be range), I had the unit as a hybrid thinking I needed that on to be a melee unit but removing that seems to have fixed it. Not sure if the melee and range attack animations were cancelling each other out, but I don't really need the hybrid features for now.

    It really is a great kit you have developed and will express it in a future review.
     
  46. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    26
    Hi Song it think I've found a bug where the game freezes when a unit in overwatch state kills a target.

    This is what's happening in the log. I'll see if I can hunt down the problem this end, any pointers from yourself or anyone would be appreciated!

    overwatch UIMessage (UnityEngine.RectTransform)
    UnityEngine.Debug:Log(Object)
    TBTK.UIMessage:_DisplayMessage(String) (at Assets/TBTK/Scripts/UI/UIMessage.cs:83)
    TBTK.TBTK:OnGameMessage(String) (at Assets/TBTK/Scripts/TBTK.cs:29)
    TBTK.GameControl:DisplayMessage(String) (at Assets/TBTK/Scripts/GameControl.cs:345)
    TBTK.Unit:AttackOverWatch(Unit) (at Assets/TBTK/Scripts/Unit.cs:793)
    TBTK.Unit:CheckOverWatch(Unit) (at Assets/TBTK/Scripts/Unit.cs:743)
    TBTK.Unit:TriggerOverWatch() (at Assets/TBTK/Scripts/Unit.cs:722)
    TBTK.<MoveRoutine>d__182:MoveNext() (at Assets/TBTK/Scripts/Unit.cs:689)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)



    fix this
    UnityEngine.Debug:Log(Object)
    TBTK.Unit:GetDestroyDuration() (at Assets/TBTK/Scripts/Unit.cs:905)
    TBTK.<AttackRoutine>d__190:MoveNext() (at Assets/TBTK/Scripts/Unit.cs:866)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
     
  47. VFXROB

    VFXROB

    Joined:
    May 4, 2015
    Posts:
    26
    Here is a video example.
     
  48. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,340
    There's no error in your video. I've tested thing on my end and everything seems to be fine. Can you replicate this consistently? If not, I'm going to say this is one of those raw bug that doesn't happen everytime and very tricky to hunt down. So it's probably more time-efficient to put in a fail safe.

    I do know what is the problem (just not what cause it). It's at line-693 where the code got stuck. You can put in a timer there to break from the loop once it exceed a certain waiting time, when you know for sure things has gone wrong. Make sense?
     
  49. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    Thanks for the asset Songtan. I have been creating units and I'm able to add them and they work well, but they seem to disappear from my units list after a while and I have to remake the unit. Any idea how to permanently add them to the unit data base? Thanks
     
  50. Capo_291

    Capo_291

    Joined:
    Jan 17, 2019
    Posts:
    12
    I have a UnitDB but I can't find the UnitTB, I have noticed that every time I edit one of my units lets say I change their scale, they disappear from the unit list and I have to create them again in the unit editor. I tried manually adding them to the unit data base but that didn't work either. I'm sure I'm missing something simple. thanks
     
    Last edited: Jan 18, 2019