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. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Thanks for letting me know. I'm well aware of the issue. The problem is with the NGUI anchor some how reset itself to some strange position. I've fixed it but it could be a few days before I upload the next fix to AssetStore.

    Please send me an email if you want me to send you an advance fix.
     
  2. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I've encountered that before when I have the aspect set to "Free Aspect". Forgot all about it until I saw this.

    Is this something you could walk me through fixing? I've heavily edited the code and don't really want to re-do all those changes - mainly because I've lost track of all of them! I tried to keep a change log but wasn't as good about updating it as I should have been. Thanks!
     
  3. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Sure, add these to function StartBattle() in UINGUIOverlay.cs

    Code (csharp):
    1.  
    2.         UIAnchor[] anchors=thisObj.GetComponentsInChildren<UIAnchor>();
    3.         for(int i=0; i<anchors.Length; i++) anchors[i].enabled=true;
    4.        
    5.         Transform parentObj=dmgOverlayObject.transform.parent;
    6.         parentObj.GetComponent<UIAnchor>().enabled=true;
    7.  
    Then in DamageOverlayRoutine(), add this


    Utility.SetActive(obj, true);

    after the line Instantiate(dmgOverlayObject);
     
  4. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
  5. BBORNCR

    BBORNCR

    Joined:
    Jul 28, 2013
    Posts:
    16
    That worked for me. Thanks. I still have "25" in the overlay no matter what the damage is.
     
  6. BBORNCR

    BBORNCR

    Joined:
    Jul 28, 2013
    Posts:
    16
    In the Unit Editor I am trying to add the animations that my models have built-in (legacy import). In the drop down box in the Unit Editor the clips do not show up instead only the body parts!? Can anyone point me in the right direction?

    Thanks,
     
  7. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I don't see that script anywhere. I'm one update behind if that matters.
     
  8. BBORNCR

    BBORNCR

    Joined:
    Jul 28, 2013
    Posts:
    16
    Its at line 188:

    IEnumerator StartBattle(){
    UIAnchor[] anchors=thisObj.GetComponentsInChildren<UIAnchor>();
    for(int i=0; i<anchors.Length; i++) anchors.enabled=true;

    Transform parentObj=dmgOverlayObject.transform.parent;
    parentObj.GetComponent<UIAnchor>().enabled=true;

    yield return null;
    InitUnitOverlay();
    }
     
  9. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    You misunderstand. I don't have a script called UINGUIOverlay.cs in my project anywhere.

     
  10. BBORNCR

    BBORNCR

    Joined:
    Jul 28, 2013
    Posts:
    16
    Mine is in Assets-->TBTK-->TBTK(NGUI_Full)-->Scripts
     
  11. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Must be new in 1.0.6. @Songtan: any thoughts on fixing this in 1.0.5?
     
  12. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    The drop down is for selecting the Object which has the animation component. Once you select that, that should open up a field where you enter the number of animations you want to use. Then that should open another field where you drag your animation clip into. Here is a tutorial that explains this in great detail:

     
  13. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Sorry guys, I was away.

    Curious, it shouldnt happen... are you saying there's a 25 on screen all the time or every damage/miss overlay has a additional '25' on it? Anyway, try look for a gameObject in the scene, TBTK/UI_NGUI/CameraEffectrOverlay/Panel/AnchorBottomLeft/LabelDmgOverlay, delete the text on the UILabel component (which by default is 25). That should clear the issue.


    UNGUIOverlay.cs doesnt not exist in earlier version. It has only been added in v1.0.6, as of the addition of new GUI based on NGUI3. I dont think you will have the overlay offset issue if you are using the old version. It only happen in the new GUI.


    To use any animation, first you have to specify which gameObject is the animation component should be attached to. As you probably aware the structure of the unit prefab is an empty gameObject with the UnitTB component, with the rest of the mesh as the child object. So the root object may not be the gameObject where the animation should be running on. Hence the option to specify which gameObject. Once you done that, you should be able to assign whatever animation file you want to play for the action.

    @drewradley, thanks for trying to clear up matter. I didnt see your last post until I posted this.
     
    Last edited: Jan 16, 2014
  14. BBORNCR

    BBORNCR

    Joined:
    Jul 28, 2013
    Posts:
    16
    That did it! Thanks!
     
  15. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    It does happen but only when I have it set to Free Aspect and Maximize on Play. If I choose any preset aspect or don't maximize, it's fine.
     
    Last edited: Jan 16, 2014
  16. BBORNCR

    BBORNCR

    Joined:
    Jul 28, 2013
    Posts:
    16
    I erased the "25" but I still get this...

    $Screen Shot 2014-01-16 at 3.39.48 PM.png
     
  17. Sartoris

    Sartoris

    Joined:
    Dec 8, 2013
    Posts:
    21
    I'm thinking about purchasing your toolkit, but I would use it primarily to construct 2D scenes, like those in the Banner Saga or the early X-COM games. Do you think this would be possible? I suppose this would mean that each unit would have to be represented not by a 3D model, but a 2D one, which would need to have a certain number of animations attached to it. Would this be possible with this tool? I'm asking because I've only seen the demos with 3D units.
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    @drewradley, I got it. I've sent you a fix via email

    @BBORNCR, I see, that's not the damage overlay. It's intended to be the hit point of the unit. However I must have missed some code. Currently it doesnt do anything but has the text stuck at 25. I can send you a fix if you wish. While I'm at it, you can let me know if you want the label to show the unit HP or just hide the text.

    @Sartoris, It's possible. The asset used are irrelevant for the core mechanic to work. There are 2 issues I can see tho. First, you may not be able to get the toolkit to work exactly like what you seen in Bannar Saga or old school X-Com. I'm not familiar with either of the games you mentioned. But my assumption that there will be limiation if you are trying to get the tookit to emulate other game 100%. Then there's the animation. I take it you mean to animate the sprite? I'm afraid the toolkti doesnt support 2D sprite animation, you will have to use a 3rd party solution like the 2D toolkit or write your own custom code to handle that. Either way, the would require you to do some coding.

    Here's an example of the TBTK using 2D asset, done by a user - http://www.budleiser.com/2013/09/21/game-design-video-tutorial-geometric-progression-unity-and-turn-based-tool-kit-tbtk/
     
  19. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Thanks! Got it working. You left a "ratioY" in the GetScreenPosition() that I had to change to just "ratio" but other than that it works nice. Thanks again!
     
  20. Sartoris

    Sartoris

    Joined:
    Dec 8, 2013
    Posts:
    21
    Thank you for answering, and for the link. Using TBTK the way that user does it would work just fine for me, so I think I'll purchase your toolkit.
     
  21. BBORNCR

    BBORNCR

    Joined:
    Jul 28, 2013
    Posts:
    16
    Unit HP would be perfect. Thanks!
     
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    @Sartoris, in that case, I thank you in advance.

    @BBORNCR, I dont have your email address so I pm'ed you instead. In the future, it would be helfpul if I can email you directly.
     
  23. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Just a quick announcement that a fix update (v1.0.6f1) is out and live on AssetStore. The bugs fixed are as follow:
    • fix a few errors that happened when restarting a level
    • fix the game over screen so the stats are shown/hidden properly
    • fix bug where overlay is not positioned correctly
    • fix bug where damage overlay does not show up correctly with cover system enabled
    • fix bug with unit effect where some of them will not be cleared after the effect duration has due
    • remove a few warning message on unity4.3
     
  24. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    What would I need to change to make a 2d unit change images instead of facing? So rather than the model rotating to a new direction when it moves or gets attacked, it changes the image. I can handle the code, but I need to know where to change; what the best way to get the facing direction; and how to stop it from turning. I am using the latest version.

    Thanks!
     
  25. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Look for the function RotateToUnit() in UnitTB.cs. That's where the unit rotate itself to face the target. If you dont need the unit to face its target, you can get rid of the function. Alternatively you can insert your code here to change the image/sprite. The best way to get the direction of course is to use the Quaternion.LookRotation function. You can find the example in the very function that I told you .
     
  26. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Thanks! I totally missed that function!
     
  27. BBORNCR

    BBORNCR

    Joined:
    Jul 28, 2013
    Posts:
    16
    There is a problem with selections underneath the GUI. For example, if one tries to select a Unity Ability and there happens to be a viable hex underneath the button, both the button and the hex are selected at the same time (ie. the unit moves out of position and selects the ability). According to this thread the correct and default behaviour for NGUI should be that when the mouse is over any GUI item nothing more should be selected.

    http://www.tasharen.com/forum/index.php?topic=1030.0
     
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Noted. I thought I fixed the issue in the last update, apparently not. I'll get to it right away.

    By the way, a public announcemet: I'll be away and traveling for the next two weeks starting tomorrow. Obviously I wont be as readily available as I currently am. So my apologize in advance for the slow respond.
     
  29. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    If it's not too difficult or lengthy, can you let us know how to fix it? As usual, I have HEAVILY edited the code and would rather make one new change than to redo all the other changes.

    Also, when in Play and maximized, I pause it and unpause it and the GUI gets all out of alignment. Is that going to be an issue in a final game? i.e. if I minimize a game in progress and then maximize it, will it do this or is this only something in the Unity editor?

    Thanks again!
     
  30. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I dont really want to cluttered the thread so I've emailed the steps to fix the issue to you. Please note that this shouldnt be affecting mobile build, so if you are building for mobile only, this should be a non-issue.

    I'm guessing you have the "Maximize on Play" enabled? And the GameView tab is resized when you pause the game? The Anchor of NGUI can be erratic (honestly I'm not really sure how it works) at time when you have screen resolution change in runtime, putting all the UI element out of alignment. But I imagine this shouldn't be an issue in actual build. I would suggest you to really get to know about how to set UIAnchor properly for your actual release build. This as far as I'm concern, is a NGUI issue. Hope you understand.

    By the way, I'm in the process of re-uploading the fix to AssetStore. Anyone who is not interest in update their project for a single bug please email me so I can send you the step to take to fix the issue.
     
  31. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Got it. Thanks! I appreciate it!

    I figured it was probably an issue with NGUI and suspected what you told me. As long as it's not going to be a problem with a build, I certainly don't care that much either.
     
    Last edited: Jan 23, 2014
  32. Grendal1971

    Grendal1971

    Joined:
    Oct 22, 2013
    Posts:
    14
    Anyone else getting the following argument exception when trying to let TBTK auto populate the grid?
    It works fine until I unclick the toggle that allows player to place starting units.

    This is while using the full NGUI package, not default, haven't tried default.

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[Tile].get_Item (Int32 index) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    UnitControl._AutoPlaceUnit () (at Assets/TBTK/TBTK (Base)/Scripts/C#/UnitControl.cs:753)
    UnitControl.Start () (at Assets/TBTK/TBTK (Base)/Scripts/C#/UnitControl.cs:198 )
     
    Last edited: Jan 25, 2014
  33. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I believe that is a bug that I've fixed since the update 1.0.6f1. I've just tried it with latest release without such problem. Are you using the latest version?
     
  34. Grendal1971

    Grendal1971

    Joined:
    Oct 22, 2013
    Posts:
    14
    I am using 1.0.6f2.
    I have been getting it quite a bit, but I have been able to correct it. Its the result of having a setting in one of the controls that TBTK doesn't know how to handle. Example: Setting up faction 1 with a spawn grid but then also placing faction 1 spawn points manually in painter. I have learned to use the error as a stop point to go back and figure out where I screwed up. I have gotten it with units, and collectibles.

    That said, I have gotten my first scene from scratch built and working wonderfully. :)
     
  35. Pathlesspath

    Pathlesspath

    Joined:
    May 8, 2013
    Posts:
    13
    I'm edit model to sprite. How to fix angle of hero when it get hit or move.
    goo.gl/S2S1Yp

    Any idea :confused: ? , Thanks in advance.
     
    Last edited: Jan 27, 2014
  36. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I see. I will play test it a bit and try to replicate the error. Probably it's something that is avoidable.

    For attacking, you can disable the RotateToUnit() function in UnitTB.cs. Simply comment off all the code in the function will do. For movement tho, you will need to remove certain lines of code in MoveRoutine(), again in UnitTB.cs. It's from line672 to 680. You will be able to differentiate the code as it contains quite a lot of keyword, rotation.
     
  37. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    If you want to keep the sprite from rotating completely, there is an easier way than editing the TBTK code. Here is a very simple code that keeps the child of a game object from rotating:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class SpriteController : MonoBehaviour {
    5.     public Transform myTrans;
    6.     public Quaternion rotation;
    7.     // Use this for initialization
    8.     void Awake()
    9.     {
    10.          myTrans=this.transform;   
    11.                           rotation=myTrans.rotation;
    12.     }
    13.     void Start () {
    14.    
    15.     }
    16.    
    17.     // Update is called once per frame
    18.     void Update () {
    19.    
    20.     }
    21.     void LateUpdate () {
    22.         myTrans.rotation=rotation;
    23.     }
    24. }
    25.  
    Keep in mind this will keep the sprite locked in one direction so if you rotate the camera, you will also need to rotate the sprite. It's a bit more complex and I haven't done it since I am using a camera that doesn't rotate.

    edit: if you change "rotation=myTrans.rotation;" to "rotation=new Quaternion(0,0,0,1);" it will let you to use a different facing to place the units and it will automatically update at run time.
     
    Last edited: Jan 27, 2014
  38. Pathlesspath

    Pathlesspath

    Joined:
    May 8, 2013
    Posts:
    13
    Thank you very much for your help i really appreciate it.

    For class SpriteController is work. Thank again drewradley .:D
     
  39. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Getting an error when I restart a lost battle and lose again:

     
  40. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Sorry if you've already answered this in the thread but I haven't yet gone through all 20 pages. I'm interested in making a turn-based dungeon crawler game similar to Warhammer Quest. Would this tool-kit be a good base for the map? I think the square grid would work but I'm not sure whether you can build multiple small rooms and connect them together with this kit?

    Here is a link to the Warhammer Quest game for reference:

    https://itunes.apple.com/us/app/warhammer-quest/id573516833?mt=8
     
  41. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Actually, looking at the demo, I think it would work for what I have in mind. Performance-wise, what are the limits on map size? How large a map could you have in a single level (with fog of war) and still run reasonably well on a fairly modern ipad or similar tablet?
     
  42. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    Can this be the grid be overlaid on non-uniform terrain? I know you don't calculate move penalties for uneven terrain but I can do that.
     
  43. Grendal1971

    Grendal1971

    Joined:
    Oct 22, 2013
    Posts:
    14
    I get it in the following setups:

    1. When I have faction 0 setup in gamecontrol script but then assign a faction 0 in grid manager or make a faction 0 spawn area in gridmanager.
    2. When I fail to make spawnable hexes for faction 0 using gridmanager.

    Both are clearly user error, but maybe something could be added to warn or remind.
     
    Last edited: Jan 29, 2014
  44. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    One more question, how difficult would it be to create units with melee attacks rather than ranged attacks? Would it be as simple as setting the range of a unit's attack to zero? Would the AI then know that they need to move next to the target before resolving its attacks? If not, how complicated do you think making this change to be?
     
  45. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Both Melee and Ranged attacks with different animations and hit chances are already in place. You can even use both.
     
  46. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Thanks ... that sounds awesome. I think I'll go ahead and buy.
     
  47. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    My apologizes for the slow respond!

    @drewradley,
    Thanks for the bug report. I'll get it fixed. If you want to do it yourself, check OnDisable() in UNNGUI.cs, make sure all the + sign are changed to -sign. That should be it. Careless mistake on my part, sorry for that.




    @Rajmahal,
    This one is a tricky bit. Due to the fact that each tile on the grid is an individual gameObject, a large map can create a huge amount of gameObject in a scene. And that could be a problem. The maximum I would recommend is 50x50. That's how high I've manage to get it running without any problem. Any higher, it's hard to say.
    The kit support both melee and range attack. You can even create hybrid unit that uses both melee and range attack. The way it work is melee attack is used if the target is within melee attack range. Beyond that, range attack is used. AI unit will only try to get in attack range regardless of the attack type. So a hybrid unit may only do range attack most of the time.




    @Fuzzy_Slippers,
    It's doable but you will either have to modify the code a bit or adjust the individual tile directly. See each tile on the grid is an individual gameObject which can be moved around. You can adjust the y-axis position to fit the height of the terrain. If you are somewhat adept with coding, you can easily add a vertical raycast check for each of the tile to be mapped on the terrain.




    @Grendal1971,
    Thanks for the info. I'll see if I can put it some condition check to make that setting mutual-exclusive.
     
  48. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Thanks for the replies.

    For a dungeon crawler, I wouldn't really need a large square map but instead would build a map that had several corridors and rooms linked together. The rest of the space would not be accessible. Therefore, would this kit allow for this kind of design? Could I build a large map (50x50) but only have a small number of tiles within that map that can be moved on and the rest as impassable? Would that improve performance in any way? Would the impassable tiles still be game objects or can they just be some sort of empty space within the grid that aren't actual tile game objects?

    Sorry if my questions aren't clear ... it's a tricky sort of thing to explain.
     
  49. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Actually, I looked again at your square grid / fog of war / cover system example and I realized that it would work for a dungeon crawler very well. If it can handle something up to 25x25 squares then that should be fine for a typical dungeon crawler level. On my to buy list.

    Thanks!
     
  50. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Thanks! Who knew two little plus signs would cause so much trouble? Just goes to show what a fine balancing act coding is!