Search Unity

TowerDefense ToolKit 4

Discussion in 'Assets and Asset Store' started by Song_Tan, Apr 18, 2012.

  1. WilliamDocherty

    WilliamDocherty

    Joined:
    Feb 8, 2018
    Posts:
    2
    Hi

    New user to TDTK - I had it all working fine under 2017.2 personal edition, but I've now upgraded to 2017.3.0f3 personal edition and drag and dropping towers onto the grid no longer works. I've tested with a new clean project and same result. Any ideas?

    UPDATE: Setting Build Mode to "Point N Build" in the UI setting works - so I can use that in the meantime.

    Cheers
    William
     
    Last edited: Feb 8, 2018
  2. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for bring this to me. Are you using the latest version of TDTK? If you look in Update() in TowerManager.cs, there should be a line 'if(Input.touchCount==0) _ExitDragNDropPhase();' (line185 if you are using latest). Just remove that and you should be fine.
     
  3. jim00

    jim00

    Joined:
    Feb 1, 2015
    Posts:
    57
    Hi songtan, you have updated to current ver. 4.0.1 f3 but when i install the package is version 4.0.1 f2. can you update to f3, thanks.
     
  4. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    4.0.1 f3 is a compatibility update for latest unity. You need to download it using Unity2017.2 or above. If you are still using older version of unity, there's really no reason for you to update at all.
     
  5. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Hu, now I know why this isnt working any more hopefully the upgrade will fix my issue :)
     
  6. WilliamDocherty

    WilliamDocherty

    Joined:
    Feb 8, 2018
    Posts:
    2
    HI

    Thanks for the fast response - commenting out that line of code fixed it. Drag & drop is working again.

    Cheers
    William
     
  7. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Hi. What are the differences between TBTK and TDTK ?
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It's two entirely different framework. TDTK (Tower Defense ToolKit) is for making tower defense game. TBTK (Turn-Based ToolKit) is for making turn based game.
     
  9. NhatNM

    NhatNM

    Joined:
    Feb 27, 2018
    Posts:
    62
    Hi, I'm new comer to Unity and I want try start with TDTK, bought it. Have any video tutorial for newbie?
    I'm trying training with your scenes demo. I have some stupid questions:
    - How to do with each scene. When I throw more than a scene to hierarchy, it's show all in scene window.
    - How link scene A to scene B. Example from menu, click to button for start map game
    Sorry my stupid questions but I need help. Thank you very much
     
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There are some video tutorials based on older version of TDTK. You can just search for TDTK tutorial on youtube. However I would recommend you to just go through the documentation. It should run you through the basic and give you an idea of what you can do with the toolkit.

    First question: You don't throw scene to the hierarchy window. The scene are designed to run independently of each other. Just load them by double click on them and they are good to go.

    Second question: If you select the object GameControl in the scene, you will find two variables 'MainMenu Name' and 'NextScene Name'. These are the name of the scene to load if you press the menu or next level button in the game. If you add all the scenes to BuildSetting and run any of them (note that you can't load a scene in runtime unless it has been added to the BuildSetting), you can navigate between them using the in game menu just like you would in a game.

    Hope this help.
     
    NhatNM likes this.
  11. NhatNM

    NhatNM

    Joined:
    Feb 27, 2018
    Posts:
    62
    Thank you very much :)
     
  12. NhatNM

    NhatNM

    Joined:
    Feb 27, 2018
    Posts:
    62
    Hi, I'm nearly can control TDTK. With your scenes demo, I have some other questions:
    - How can unlock buttons under Canvas_HUDButtons, I can't move them
    - I know how to create new creeps, but how to put only new creep to only target wave I want? Example a boss will appear at that wave
    - Why you didn't place all menus/buttons to one side for easy edit? Now I must repeat edit them on each map
    - Is possible show HP's towers?
    - Would you support multi languages, path editor and map editor in future?
     
  13. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    They are being control by the HorizontalLayoutGrouyp component in UIHUBButtons. You need to disable or remove that component before you can manually position the buttons.

    Use SpawnEditor in the drop down menu. That is what you use to set what creep will be spawned at what wave. You will see.

    In case you haven't notice, the root object of the ui (named 'UI') is a prefab. You can just edit one in any scene, then apply it to the prefab (by pressing the Apply button on the top-right corner of the Inspector). That will effectively change what you have in the other scene. Alternatively, you can just copy and paste the whole game-object across different scene. If you are not sure what is prefab, I would suggest you go through this and this.

    Now that you mention it, I realize that tower will never show any HP on screen. I'm surprise not one mention this before. An oversight from me, I'll fix it in the next update.

    I'm afraid not.
     
    NhatNM likes this.
  14. NhatNM

    NhatNM

    Joined:
    Feb 27, 2018
    Posts:
    62
    Thank you very much :)
     
  15. NhatNM

    NhatNM

    Joined:
    Feb 27, 2018
    Posts:
    62
    Hi, I'm here again. I found some little bugs (maybe, not sure):
    - Tested Demo_BranchingPath map on mobile, after do rotate and touch something to screen, its camera is random auto move to right side I tried disable all options in its Camera Control but this bug still alive
    - Enegry Capacity II is require upgraded Enegry Capacity II :D
    - If enable Cursor Drag, when press and hold towers or skills, its camera is auto move, there's hard to target correct location. If disable it, the map is small on mobile, if zoom-in then camera can't move to what location I want
    - Demo__Menu isn't scale resolution while rotate on mobile. It's look bad
    Btw, could you teach me how to edit Terrain in your demo maps? I want add more space, change its textures.
    How can touch to screen for target location in map then touch to tower for build tower to that location?
     
    Last edited: Mar 3, 2018
  16. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for letting me know. I'll look into it.

    This is not a bug. You don't have to use it in such way. There are many feature in the framework that are mutually exclusive when it comes to usability. It's simply a design decision you have to make for your game. You wouldn't enable cursor drag when you are using drag and drop build mode. If you disable cursor drag, you don't design a big map where the user need to move the camera around.

    I don't think I have any terrain in any of the demo scene. But you can just add your own. Here's the thing, you can add whatever gameobject (or terrain) you want to TDTK scene, as long as they don't have any collider on them, they wouldn't interfere the game play. Anyway, this is a big subject off itself. If you are not sure where to start, there are a lot of good tutorial out there.

    You mean a 'PointNBuild' mode? Try change the build mode on UI from 'Drag N Drop' to 'Point N Build'
     
    NhatNM likes this.
  17. NhatNM

    NhatNM

    Joined:
    Feb 27, 2018
    Posts:
    62
    I have bothered you too much. You helped me alot. Thank you very much
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Don't worry about it. I'm glad to help. :)
     
  19. NhatNM

    NhatNM

    Joined:
    Feb 27, 2018
    Posts:
    62
    Hi, it's me again. I found a little bug again: in AudioManager, "Player Won" and "Lost Life" functions aren't work, "Player Lost" function is working wrong its target (it's work at player losting life)
    I'm trying improve your scenes demo, I have some new trouble need ask
    - Is volume setting menu unavailable? I didn't see it at anywhere. I made a music playing in background by Audio Source, now I want a volume control for your sounds effect and my musics
    - I can't change new models, I don't know how to do with your TargetPoint cube, could you teach me?
    - I tried making new background, but my code for auto rotate isn't work, placed it at Main Camera. What's wrong with me?

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class RotateSky : MonoBehaviour {
    public float RotateSpeed = 1.2f;

    // Update is called once per frame
    void Update () {
    RenderSettings.skybox.SetFloat("_Rotation", Time.time * RotateSpeed);

    }
    }

     
  20. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There's indeed a bug with the AudioManager. I'll fix that.

    There's no volume setting. You will have to add it yourself.

    I don't get what you mean by you can't change model. How? It gives you error? Try go through the documentation, there's a section there that show you what you should do when it comes to make sure the configure a prefab to use custom model.

    Nothing is wrong with your rotate skybox code as far as I can tell. But you should know that if you are using the default skybox in the demo scene, you won't be able to see observe anything since the skybox that I'm using have same view on all 4 sides.
     
    NhatNM likes this.
  21. NhatNM

    NhatNM

    Joined:
    Feb 27, 2018
    Posts:
    62
    Yes, have alot documents around the world, I don't know read what I need. Thank you very much
     
  22. jim00

    jim00

    Joined:
    Feb 1, 2015
    Posts:
    57
    there is something wrong with the release of ver 4.0.1 f3, the tower in the demo can't be selected. (my Unity ver is 2017.3.1f1)
     
  23. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There's a known issue with the drag and drop build mode. But as far as I can tell, tower selection (selecting active tower) are working properly. Which demo scene are you using?
     
  24. jim00

    jim00

    Joined:
    Feb 1, 2015
    Posts:
    57
    all the demo scene, I just can't drag & drop the tower into the box to build the tower during game time. I have try to install TDTK twice in different project.
    Btw, anyone have such issue?
     
  25. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Yes, like I've said, there's a known issue about drag and drop build mode.

    There's a new update that just gone live now. Please use that. It should fix the problem.
     
  26. jim00

    jim00

    Joined:
    Feb 1, 2015
    Posts:
    57
    thanks for the quick respond, i will give it a try
     
  27. hermolenda

    hermolenda

    Joined:
    Apr 9, 2017
    Posts:
    11
    Hello!
    I am working with ur td asset. I dont know how to change simple grid size, what i mean is that when i am working on platform (with build platform script) by changing scale of it, it changes grid amount not its size. Is there any parameter like
    diameter of grid or sth like that?
     
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Look for TowerManager in the scene, there should be a parameter 'Grid Size'. That is what you are looking for.
     
  29. hermolenda

    hermolenda

    Joined:
    Apr 9, 2017
    Posts:
    11
    Oh thanks a lot
     
  30. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Hello, few questions.

    It looks to me that when a unit gets hit and I call UITextoverlay damage it only creates one each time. I never see multiple ones on the screen. Why is this?? What do I need to do to fix that.

    Also, my camera moves along with the creeps how can i get the UI text damage to display above the units more so then in random spots on the screen.
     
  31. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It should support multiple text instance on screen. Thing is only one text instance will be created if each time UIOverlayText.Show() is called. If you need to display multiple one on screen, you need to call multiple time. Also, the overlay will show up in a fixed position with respect to the position you passed. So if you call multiple one in the same frame but given it the same position and same thing to display, they might all be stacking up perfectly and you can't tell that there are multiple one. You can fix this by add a slight randomize value to your position.

    Have you change the main camera? The position of the text is determined using the main camera (the camera showing the gameplay and by default the one in CameraControl, with tag 'Main Camera'). If you are using another one right now, you need to change the tag of that camera to 'Main Camera' and make sure no other camera in the scene is using that tag.
     
  32. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Ah got it I was calling the second layer of the UIOverlayText Show instead of the first with the listeners. My bad! Also, you have a new version of the 4.0 branch, with UI fixes can you elaborate more on that. I have modified the kit and would like to upgrade the UI if there was any changes, or to what I will be using.
     
  33. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    What version are you using? There's no change at all concerning the UI with the latest update. If you haven't modify the UI at all and wish to update the UI, you can just import only the UI script. I had them placed in the separate folder, should be easy enough.
     
  34. hermolenda

    hermolenda

    Joined:
    Apr 9, 2017
    Posts:
    11
    Hi all
    Is there any easy way to make wall build platforms??
     
  35. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Can you explain what exactly do you mean by wall? Just a vertical object in the scene? Do you mean to build tower on vertical surface?
     
  36. hermolenda

    hermolenda

    Joined:
    Apr 9, 2017
    Posts:
    11
    Yes i would build it on vertical
     
  37. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid you can't. It's just the limitation of the framework. To do that you will have to modify a lot of stuff.
     
  38. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    Hi.
    Can you help?
    Question about saving and loading. Can you give an example? What should I do with the code from TDSave to get a simple save and load perk. (Porting perk to another level) Should I create a new script? Assign it to the Perkmanager in the scene? What should be in this script? Need to make changes to the Perk manager script? Trigger loading at the beginning of a level and saving at the end? How?

    Thanks.
    Sorry for my English.
     
  39. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    I see in TDSave

    namespace TDTK {

    public class TDSave : MonoBehaviour {


    public static void SaveGeneralProgress(){
    //level progress
    PlayerPrefs.SetInt("TDTK_HighestLvlID", GameControl.GetHighestLevelID());

    //resource
    List<int> rscList=RscManager.GetCachedList();
    PlayerPrefs.SetInt("TDTK_RscCount", rscList.Count);
    for(int i=0; i<rscList.Count; i++) PlayerPrefs.SetInt("TDTK_Rsc_"+i, rscList);

    //Perk
    PlayerPrefs.SetInt("TDTK_PerkRsc", PerkManager.GetCachedRsc());
    List<int> perkList=PerkManager.GetCachedPurchasedIDList();
    PlayerPrefs.SetInt("TDTK_PerkCount", perkList.Count);
    for(int i=0; i<perkList.Count; i++) PlayerPrefs.SetInt("TDTK_PerkID_"+i, perkList);
    }

    //call this in PerkManager Awake(), replace it with rscList
    public static List<int> LoadRsc(){
    List<int> rscList=new List<int>();
    int count=PlayerPrefs.GetInt("TDTK_RscCount", 0);
    for(int i=0; i<count; i++) rscList.Add(PlayerPrefs.GetInt("TDTK_Rsc_"+i, 0));
    return rscList;
    }


    public static int LoadPerkRsc(){ return PlayerPrefs.GetInt("TDTK_PerkRsc"); }
    //call this in PerkManager Awake(), replace it with purchasedPrefabIDList
    public static List<int> LoadPerk(){
    List<int> perkList=new List<int>();
    int count=PlayerPrefs.GetInt("TDTK_PerkCount", 0);
    for(int i=0; i<count; i++) perkList.Add(PlayerPrefs.GetInt("TDTK_PerkID_"+i, 0));
    return perkList;
    }

    }

    }
     
  40. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    What should I do to save and load ? Create two new scripts and copy them ?

    //Perk
    PlayerPrefs.SetInt("TDTK_PerkRsc", PerkManager.GetCachedRsc());
    List<int> perkList=PerkManager.GetCachedPurchasedIDList();
    PlayerPrefs.SetInt("TDTK_PerkCount", perkList.Count);
    for(int i=0; i<perkList.Count; i++) PlayerPrefs.SetInt("TDTK_PerkID_"+i, perkList);
    }

    //call this in PerkManager Awake(), replace it with rscList
    public static List<int> LoadRsc(){
    List<int> rscList=new List<int>();
    int count=PlayerPrefs.GetInt("TDTK_RscCount", 0);
    for(int i=0; i<count; i++) rscList.Add(PlayerPrefs.GetInt("TDTK_Rsc_"+i, 0));
    return rscList;
    }


    public static int LoadPerkRsc(){ return PlayerPrefs.GetInt("TDTK_PerkRsc"); }
    //call this in PerkManager Awake(), replace it with purchasedPrefabIDList
    public static List<int> LoadPerk(){
    List<int> perkList=new List<int>();
    int count=PlayerPrefs.GetInt("TDTK_PerkCount", 0);
    for(int i=0; i<count; i++) perkList.Add(PlayerPrefs.GetInt("TDTK_PerkID_"+i, 0));
    return perkList;
     
  41. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You don't need all of that. You can use TDSave.cs as it's. This is all you need (note that they are just code being extract from the existing one).
    Code (csharp):
    1. public static void SavePerk(){
    2.    PlayerPrefs.SetInt("TDTK_PerkCount", perkList.Count);
    3.    for(int i=0; i<perkList.Count; i++) PlayerPrefs.SetInt("TDTK_PerkID_"+i, perkList[i]);
    4. }
    5. public static void LoadPerk(){
    6.    List<int> perkList=new List<int>();
    7.    int count=PlayerPrefs.GetInt("TDTK_PerkCount", 0);
    8.    for(int i=0; i<count; i++) perkList.Add(PlayerPrefs.GetInt("TDTK_PerkID_"+i, 0));
    9.    return perkList;
    10. }
    Then you simply call TDSave.SavePerk() when you want to save. This can be done anywhere, on any script. So put it in a button callback, or when you load a new scene. Up to you.

    For loading, add purchasedPrefabIDList=TDSave.LoadPerk() in the first line of Start() in PerkManager.cs. That's should be all.
     
  42. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    Thanks. But now I at all not understand.. o_O
     
  43. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    Well, I as you said added in Perkmanager.cs purchasedPrefabIDList=TD Save.Load Perk ();

    like this screenshot

    Next in TDSave.cs Change ike this screenshot

    Errors in TDSave.cs

    Assets/TDTK/Scripts/PerkManager.cs(85,42): error CS0029: Cannot implicitly convert type `void' to `System.Collections.Generic.List<int>'

    Assets/TDTK/Scripts/Support_NotInUsed/TDSave.cs(11,41): error CS0103: The name `perkList' does not exist in the current context

    Assets/TDTK/Scripts/Support_NotInUsed/TDSave.cs(12,19): error CS0103: The name `perkList' does not exist in the current context

    Assets/TDTK/Scripts/Support_NotInUsed/TDSave.cs(12,77): error CS0103: The name `perkList' does not exist in the current context

    Assets/TDTK/Scripts/Support_NotInUsed/TDSave.cs(18,4): error CS0127: `TDTK.TDSave.LoadPerk()': A return keyword must not be followed by any expression when method returns void

    Thanks for your help. Sorry for my English
     

    Attached Files:

    Last edited: Apr 13, 2018
  44. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    TDSave.cs
     

    Attached Files:

  45. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    My bad, there has been some syntax error in the code I show you. It should have been:
    Code (csharp):
    1.  
    2.        public static void SavePerk(){
    3.            List<int> perkList=PerkManager.GetCachedPurchasedIDList();
    4.            PlayerPrefs.SetInt("TDTK_PerkCount", perkList.Count);
    5.            for(int i=0; i<perkList.Count; i++) PlayerPrefs.SetInt("TDTK_PerkID_"+i, perkList[i]);
    6.        }
    7.        public static List<int> LoadPerk(){
    8.            List<int> perkList=new List<int>();
    9.            int count=PlayerPrefs.GetInt("TDTK_PerkCount", 0);
    10.            for(int i=0; i<count; i++) perkList.Add(PlayerPrefs.GetInt("TDTK_PerkID_"+i, 0));
    11.            return perkList;
    12.        }
    13.  
    Now the only thing you need is to Add TDSave.SavePerk(); at where you want to save.
     
  46. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    Good. Now TDSave.cs Looks like this. there are no errors.
     

    Attached Files:

  47. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    Sorry.

    Now the only thing you need is to Add TDSave.SavePerk(); at where you want to save. o_O Can you show how?
     
  48. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    in a Scene, an empty object is disabled. In the script object. By event (trigger) the object is enabled. It works. What does the script for saving on the object look like?
     

    Attached Files:

  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Well, if you just want to auto save the perk, the easiest way would be just add this function in PerkManager.cs
    Code (csharp):
    1.        void OnDisable(){
    2.            TDSave.SavePerk();
    3.        }
    For your information, OnDisable() is called every time the component is disabled. Like when the game object is destroyed, or the scene is being unload when you load a new scene.
     
  50. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    You don't understand, it's my English. :(