Search Unity

TurnBased-Toolkit (TBTK)

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

  1. Arialle

    Arialle

    Joined:
    Oct 30, 2014
    Posts:
    10
    Thank you once again for your speedy reply!
     
  2. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    A public service announcement: the quick fix for the AI bug is live now.
     
  3. Pedro-Oliveira

    Pedro-Oliveira

    Joined:
    Aug 1, 2013
    Posts:
    25
    Hello again, @songtan.
    I would like to know if there is a way to tweak the cover system to make a unit get the cover bonus just for being adjacent to an obstacle/wall instead of behind it. Or at least if it's possible to make the "detection angle/zone" wider and therefore easier to get the dodge bonus.
    Or do you think a change like this means rewriting most code?
    Anyway, can you give me some advice in which parts of the code should I modify?

    Thank you in advance.
     
  4. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You can adjust the 'Effective Angle' of the cover angle system in GameControl. It determine at which cutoff angle of the cover bonus from any direction. If you increase the value to something sufficiently big (>360 for instance), the cover bonus will apply regardless of the attacking direction. Effectively make it so that as long as the unit is adjacent to a wall or obstacle, it's in cover for attack from all direction.

    Hope this help.
     
  5. Popcony

    Popcony

    Joined:
    Apr 14, 2014
    Posts:
    17
    Is there going to ever be a traditional loadout system? What I mean by that is will I ever be able to ad units, and equip them with different kinds of weapons for different effects or stats?

    Cheers!
     
  6. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid there's no plan to add such feature in the foreseeable future. If I'm honest they are too many variables in how such system could be interpreted. As a result in term of coding and execution of the framework, it's difficult to keep it universally applicable in different instance. Adding the fact that there has to be a UI that support it makes it a very tricky thing to pull off. If there comes a day I've manage to figure out a solution I might get to it. But as it's, I wouldn't hold my breath for it.

    If you really need it in your game, I could do a custom loadout system extension of the framework for you. But obviously that would fall outside the scope of support have to be count as extra freelance work. I hope you understand.
     
  7. Popcony

    Popcony

    Joined:
    Apr 14, 2014
    Posts:
    17
    That's okay, I think I can use a champion-based design instead. Have each champion have unique "Abilities" as their different weapons. Or think of it like a move-set (o la Pokemon).

    My last question: is there a way to have unique animations for every "Ability" Including turning the unit towards the target before executing the animation. Not that it matters.
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid there's no animation for ability as of current version. However it should be relatively straight-forward to add. I'll see if I can do that in the next update.
     
  9. Viking1972

    Viking1972

    Joined:
    Jul 24, 2009
    Posts:
    74
    The only features missing, as far as I can tell, is

    - a minimum range for artillery
    - some rules for moving through different types of terrain
    - some rules for attacking/defending on different types of terrain (example: -1 to movement in a forest)
    - some rules for attacking/defending on different types of terrain heights (example: -1 to attacking when attacking uphill)
     
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for the suggestion. I have to say that I have considered all the things you have suggested in the past, even go as far as implementing them in earlier version. Unfortunately they are all more complicated than it sound (apart from the minimum range), other wise they would have been in there already. I might one day come back to see if I can add this to the new update. However please understand that I can't promise anything.
     
  11. Arialle

    Arialle

    Joined:
    Oct 30, 2014
    Posts:
    10
    Without a doubt, thank you for all of your hard work for this library. I definitively appreciate the amount of work that went into it. Personally, I never expected any one library to be a "one-stop shop" for the project that I am involved with; if anything, this has been a great starting point~! Thank you again!
     
  12. JessieK

    JessieK

    Joined:
    Feb 4, 2014
    Posts:
    148
    Hey a random suggestion I had was (And I am not sure if I am just missing this feature or something) that the "chance to hit" gets worse by a certain % the further away the target is

    So for example a unit 2 tiles away is a 80% chance to hit but a unit that's 3 tiles away is a 60% chance to hit. Just right now there's no reason to move units after a while, so a feature like this would be really cool.

    Also there is a bug with the "Add prefab to database" button, it does add the unit to the database and you can edit it in there like normal, but if you then load that unit in to a scene via the faction manager the unit won't show up in game, if you then check the faction manager to see why the whole thing crashes unity and that scene becomes unusable.
     
  13. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid there's no such system yet. But now that you have mention it, I'll give it some thought and see if I can add that in future update. :)

    As for the bug. Thanks for pointing that out. I'll check and get back to you with a fix asap.
     
  14. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I've to say I didn't manage to replicate whatever error you have encountered. Can you clarify what exactly do you mean by 'load unit into a scene via the faction manager'? I've tried both starting unit list and procedural spawning without running into any error. Also other questions: Are you using the latest version and if yes, what are the error you run into. Specifically, the full error message.
     
  15. JessieK

    JessieK

    Joined:
    Feb 4, 2014
    Posts:
    148
    Woops I had yet to update the project, all sorted now.
     
  16. GPSchnyder

    GPSchnyder

    Joined:
    Mar 23, 2013
    Posts:
    45
    Hi there. Just started a new Project with TBTK only in it as I had some problems getting it to work. I updated the Asset right before that, so it should be up to date. I aded a Hex Scene, told the game to autogenerate Grid and autodeploy the Units in the Fraction Manager, where I also chose the Basic Tank Mk I in the Fraction Manager Editor under Spawn Info. When I start the Project it seems to work, but it's not deploying the Units.
    What's bugging me is that the Fraction Manager tells me that the Spawn Group has a Tiles Count of 0, which may be the Problem. Is there a way to set the Spawn Area? If so where?

    And is there a Tutorial that features the actual recent Version, as the Videos from Version one didn't help me at all...
     
  17. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Whenever you create a spawn group, you will need to specify where the spawn will take place. In other words, on which tiles the unit can be spawned on. You can do that in GridManager. It's just like how you would place an item (unit,collectible, etc) on the grid. You select Tile as the the edit-type, SpawnArea as the tile-state and specify which spawn area you want to specify, then just click on the grid in SceneView. Make sure you have Enable Edit turned on. A tile marked as a spawn area will have a small circle on them if you have the gizmo turned on.

    I'm afraid there's no video tutorial corresponding to the current version right now. But if you haven't gone through the documentation, I would strongly recommend you to.
     
  18. GPSchnyder

    GPSchnyder

    Joined:
    Mar 23, 2013
    Posts:
    45
    I did that now, and I also marked them as deployment. None the less it doesn't work. I can add Units by myself, and it works. Which is enough for testing right now, but I really need them to automatically be placed...
    I read it, but I tend to have problems with manuals like yours, if I don't know/have seen it done once. Just a walkthrough of the Setup, like you had for your TDTK would be enough to have a rough Idea what to do.
     
  19. GPSchnyder

    GPSchnyder

    Joined:
    Mar 23, 2013
    Posts:
    45
    Created a new scene and tried it. Works. Thanks.
     
  20. gukuma

    gukuma

    Joined:
    Dec 1, 2015
    Posts:
    1
    Hi, I'm trying to write a new function that switches a unit's faction between user and AI controlled. I tried just editing the factionID, does that rebuilds the unit lists of every faction automatically? How might I best do it? Thank you for your help!
     
  21. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid that is not straight-forward by any mean. Which is the reason why it's not there in the first place. Editing the factionID is just the first step. Then depend on the turn mode you will need to do different things. If you are using faction-per-turn, you need to manually move the unit from its default faction unit list to the new faction unit list. Then you will need to reset the unit's turn data (by calling NewTurn() on the unit) so that it is ready to move again. Of course, all this is subjected to the move order. If you are not using free order, you will need to check the move order before insert the unit into the faction unit list.

    Things is easier if you are using UnitPerTurn since all unit has been filled into a allUnitList of FactionManager according to their move order. So move order is no longer a concern. But you will still probably need to put the unit in the corrrect faction unit list if the switch is permanent or the game over condition wont trigger correctly.

    Which bring me to the question of if the switch permanent. If not, you will need a way to accurately track the duration of the switch so it can be switched back.

    Finally, there's the UI and grid overlay that indicates which unit is hostile and which is friendly. The default UI doesn't facilitate this at all. You will have to modify the code so that it can support this.
     
  22. Rajmahal

    Rajmahal

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

    I need your help. I want to have my units rotate only on the y axis when looking at another unit or tile (during movement). Here is the code that rotates a unit in my version:

    Code (CSharp):
    1. IEnumerator _RotateToUnit(UnitTB unit){
    2.  
    3.         // Raj Test Code
    4.         // animationTB.PlayHit();
    5.         // end of Raj TEst Code
    6.         Quaternion wantedRot=Quaternion.LookRotation(unit.occupiedTile.pos-occupiedTile.pos);
    7.         while(true){
    8.             thisT.rotation=Quaternion.Slerp(thisT.rotation, wantedRot, Time.deltaTime*rotateSpeed);
    9.             if(Quaternion.Angle(thisT.rotation, wantedRot)<1){
    10.                 thisT.rotation=wantedRot;
    11.                 break;
    12.             }
    13.             yield return null;
    14.         }
    15.     }
    I don't know anything about Quaternions and whenever I try, I always get lost. How do I change this code so the unit just rotates towards his target tile or unit only around the vertical axis?
     
  23. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    I should explain that I have modified the vertical position of tiles to allow units to move up and down stairs. However, while this works, the rotate code makes them angle themselves in weird positions.
     
  24. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    If you want to limit the rotation to vertical axis only, you need to equalize the y-axis value of both the position. Like so:
    Code (csharp):
    1. Vector3 pos1=unit.occupiedTile.pos;
    2. Vector3 pos2=occupiedTile.pos;
    3. pos1.y=pos2.y;
    4. Quaternion wantedRot=Quaternion.LookRotation(pos1-pos2);
    Is this what you need?
     
  25. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Yep ... thanks, I figured out something similar that seems to work after posting this.

    Here's a picture by the way of my next game using this kit. This is the one that will launch after the game launching in September of this year. I took a break from polishing the September release game to work on this one.

    Screen Shot 2016-08-25 at 4.20.57 PM by Rajpreet Dhillon, on Flickr
     
  26. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Looks awesome. Is this using the same customized version you have been using?
     
  27. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Yep ... Same version. I figured it was faster than learning a new code base. I'm amazed how easy it was to add the various heights even in this old version.

    Working on the gui now. I want to make the gui much more interesting and dynamic. Also want to aff more psychology rules for the unit for things like suppression, pinning, and so on. Hopefully, I'll figure out the overwatch shooting mechanism that I couldn't figure out earlier.
     
  28. MAeStROx

    MAeStROx

    Joined:
    Mar 20, 2015
    Posts:
    15
    Hi songtan,
    I have looked at the new version, and although the major manager classes aren't static anymore which is a great thing,
    still all the major classes function calls are made through static methods.
    This is not good because when I try to use multiple battles there is no way to know to which instance to send it to.

    Is there any chance you will change it so I could tell which instance of battle it is?
    It worked when I made a Battle class and passed it to a battle controller.
    Then when a class say FactionManager wants to call say GameManager, it does battle.gameManager(...).
    And when a class wants to cause a major event it uses the battle controller, for example Unit will call battle.battleController.AttackUnit(attackingUnit,attackedUnit).
    If you make a simple controller, you can then have classes that inherit from it like network controller, which override its Attack function for example and send it over the net instead of calling it locally, then when it is recieved from server it is called locally through it's base class and everything happens as it should have.
    And this way the package can have internet multiplayer.

    Please I want to buy some liscences and have a team develop with me down the road, so I'm asking if there is a chance you will add support for this, so I could keep up with your updates with minimal changes, thanks.
     
  29. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I see what you mean and I understand where you are coming from. However for the toolkit current purpose, there's really not much point in doing that. Not only It take a lot more work to set a scene up (assign the correct instance of script to each other so they can be reference correctly) and it's a more error prone. They are harder to debug too when something goes wrong. So I hope you can understand my reluctance with going forth with your suggestion.

    I will give your suggestion some thoughts. I do want to add network multiplayer support if I can at some point (probably in the far future) so it might be worth while paving the way now. At any rate, this is not going to happen anytime soon I'm afraid. I've got enough stuff that I need to work on so I won't be doing any major update to TBTK soon. My apologies for any inconvenience.
     
  30. DarthMasta

    DarthMasta

    Joined:
    May 1, 2013
    Posts:
    2
    Hi there.

    How hard would it be to implement bigger size units? I mean only on square cells, no idea how that could work on hexes, but having units that occupy 1 square, 4 squares, 9 squares, 16 squares? Enough to "simulate" from small to very large units, similar to how Conquest of Elysium has different sized units...

    Thanks for you awesome work.
     
  31. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    I'd be interested to know that too, actually.
     
  32. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It's going to be relatively challenging I'm afraid. For a start, the path-fiding system will have to be rewrite. The current system simply won't work for unit which size exceeding a single cell. Then there needs to be a way to register a unit foot-print. How many cell it's occupied so to speak and how what cell on the grid it's occupying. Once that is done, there are other smaller details that needs to be rethinked. Thing like if a unit is within attack/effect range, etc...

    Hope this gives you some idea.
     
  33. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    Hi songtan!
    I'm in trouble with shoot objects.
    I've created an ability in the unit ability window and I've assigned a shoot obj in Targeting Settings and an effect in the Visual Effect Settings.
    When the unit fire the ability, the shoot obj does not work while the effect on the target yes.
    Another thing, I've created a shoot obj with an Hit effect linked.
    When the unit fires, the hit effect is seen in the terget unit and also in the firing.
    I can not figure out how to do.
    Thanks for the time
     
  34. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Can you elaborate in what way the shoot object does not work. It doesn't show up at all? Or it fire at the wrong place? What are the shoot object type you are using? Can you try a default shoot object and see if that works?

    There is a bug with this. Please change line84 to 85 to following to fix that:
    Code (csharp):
    1. if(!destroyHitEffect) ObjectPoolManager.Spawn(hitEffect, targetPos, thisT.rotation);
    2. else ObjectPoolManager.Spawn(hitEffect, targetPos, thisT.rotation, hitEffectDuration);
     
  35. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    The shoot obj is not showed at all and i've tried with all types: beam, effect, missile and projectile.
    I've made your changes, now the hit effect is seen only in the target unit, but is doubled!
    One is seen in the right way (when the shoot obj reach the target) and the other one immediatly when I select the target unit.
     
    Last edited: Sep 1, 2016
  36. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    My mistake. The two lines I've shown you shouldn't be there at all. You should have delete it all together.

    With that gone, I'm fairly sure the hit-effect will work correctly. Now about the shoot-object, you haven't let me know if the default shoot-object works? I've tried on my end and it worked. My guess is something wrong with your shoot-object visual setup, makes it not visible. Otherwise you won't get the second hit-effect when the shoot-object reach the target.
     
  37. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    Ok. now the it effect work well! Thank you!
    I've tried the default shoot obj but still show nothing
     
  38. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Can you try the default ability - 'Damage Target'? I'm pretty sure that one works. If not, you must have accidentally modified something. Or there would have been some error when you use the ability. Do you see any error message in the console?
     
  39. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    I deleted all of TBTK abilities to put my.
    However all the default abilities of TBTK work well.
    I'm sure have not modified the script
    I dont see any error message in the console
     
  40. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I took a thorough look at the code found a bug. That probably why your custom ability wont fire any shoot-object. Please send me an email so I can send you the fix. Very sorry for the trouble.
     
  41. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    ok! thank you! What file you need?
     
  42. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    No I mean just send me a blank email so I can reply to you with the attachment. I can't do that here.
     
  43. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    @songtan I write you ina private conversation!
     
  44. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    Hi songtan! There is a way to build a grid on multiple levels?
     
  45. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid not. Sorry to disappoint.
     
  46. govnik

    govnik

    Joined:
    Jun 30, 2016
    Posts:
    5
    When I mark a tile (Square, haven't tried Hex) as unwalkable in the Grid Manager (or Square Grid, then check/uncheck the box of the specific tile) the units can still move to that tile. Also I tried obstacles, walls, and the half versions of each and they do not appear doing play mode. Is there some obvious fix to this that I have missed, because I've tried in 2 projects (the one Im working on, and then a blank with just TBTK loaded then working in a demo scene). The Obstacle appeared once, but in play mod the unit still could move into the tile with the obstacle.
     
  47. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    When you say the unit can move into tile with obstacle, is the obstacle (the white block if you are using the default prefab) still visible on screen? If yes, then it sound like a bug. Do you have any error message show up in the console? Have you tried one of the default example scene, specifically DemoFullFeature? Can you move into the obstacle with that one? It would be very helpful if you can show me a screen shot of your grid in both edit mode and play mode.

    Just a quick check, have you left the GenerateGridOnStart option in GameControl turned on by any chance? If you do, the grid will regenerate itself when you load the scene, or start playing. You will lost whatever modification you have done to the grid in edit mode.
     
  48. govnik

    govnik

    Joined:
    Jun 30, 2016
    Posts:
    5
    Thank you for the reply, the Obstacle was the full default obstacle. I was running into errors and trying to correct them for some time and the obstacle was never appearing, then when it did the default tank could still move into it. It was an 11x12 square grid on the back row (right to left) on the left side. I believe I do have GenerateGridOnStart and Unity was having issues crashing with renderings so maybe all the times I clicked play, deploy the units, then try to move to the same tile over and over it finally just rendered the obstacle then moved before crashing. I'll play around with it again today with the GenerateGridOnStart off. Thank you for the suggestion I knew I was almost assuredly missing something that should be obvious, but got frustrated in repetition. (edit: yep the GenerateGridOnStart was my problem)

    My next step, and something I fiddled with slightly already, was I purchased other providers animated units and generally followed your custom unit video with the Skeleton (outside of the out of date parts). In the video you implied the tricky part was setting up animation and that is once again where I'm stuck. After dragging to future prefab onto the field and applying the Unit script, then theres an Animator script (do I use the one with the unit from another party, or the TBTK one?), then the setting up the appropriate animations in TBTK for thinks like Attack and Idle (do I use TBTK's or the ones that came from someone else with the unit).

    Like when I set it up and enter play mode the units play an idle animation and then just coast around using drags. The stats and dodge and all that from TBTK has worked out great though.

    Third would be how difficult would it be to replicate the Repair Unit ability into another for Repair All for your team. I glanced at it and saw the options to target all (I assume also the opposing units), but I was interested in an All Team if possible.

    I am playing around exclusively in TBTK's example scene that starts as a Hex grid in a jungle (but I altered the terrain and switch Hex for Square).
     
    Last edited: Sep 23, 2016
  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Sorry for the slow respond.

    I've made a video about setting up unit animation. There's no sound but it should show you everything you need to do.

    By default, there's no way to have an ability that applies the effect to all friendlies/hostiles. The all unit option is not really target all units on the grid, it means that the effect can be applied to all unit type (both friendly or hostile unit). The nearest hack to do this is to disable target selection of the ability and set the aoe range to very high value that it's effective covering the whole grid. That however is not an effective solution.

    It's not really that difficult to modify the code to have a unity ability to apply an effect to all friendly/hostile unit if you know the code. However consider that you have to fix the editor as well, it's not very straight-forward either. I can show you where to start if you want to do the modification. But if you can wait, I'll make sure it's there in the next update. That said, I cant promise how long you will have to wait.
     
  50. govnik

    govnik

    Joined:
    Jun 30, 2016
    Posts:
    5
    Thank you for the video

    I am trying to make my turn based game one unit for a team and then pass turn, but I want the player to be able to choose which unit to use for the turn. I went with Turn Mode: FactionUnitPerTeam and then Move Order: Free.

    What happens for me is the player that goes first can choose any unit and use it as I wanted. Then once the turn is passed the game has pre-selected which unit will move that turn. I think there's something with these couple lines (starting at I think 255?) in the Game Control script, but I don't know if that's right. Like it works correct on the first turn, then after that it isn't right. I think it might be the &&TurnControl line, but I am not good at this so any help would be very appreciated.

    public static bool CanSelectUnit(Unit unit){
    if(TurnControl.GetMoveOrder()!=_MoveOrder.Free) return false;
    if(TurnControl.GetTurnMode()==_TurnMode.FactionUnitPerTurn &&TurnControl.HasMoved ()) return false;
    if(TurnControl.GetTurnMode()==_TurnMode.UnitPerTurn) return false;
    if(FactionManager.GetSelectedFactionID()!=unit.factionID) return false;
    return true;
    }


    ____
    I changed 257 to true and it works for me now, do you know if this will mess me up somewhere down the line, or is this change safe (I am sorry if this is a stupid question I am learning as I go)?
     
    Last edited: Sep 24, 2016