Search Unity

TowerDefense ToolKit 4

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

  1. Tashaf

    Tashaf

    Joined:
    Aug 5, 2014
    Posts:
    2
    sir please help ... the UI is not working properly when click to main menu button it do'nt work .. and the is no exit game button...
     
  2. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There's a few possibility why the main menu button doesn't work. Either you haven't specify the scene name of the main menu in GameControl, or you haven't added the main menu scene to the Build Settings. The latter will give you an error message.

    Yes I'm afraid there's no exit game button. My thought process is you will have to go to main menu to exit the game. And the main menu is something you have to build yourself for your game.
     
  3. ColpColtran

    ColpColtran

    Joined:
    Oct 9, 2014
    Posts:
    27
    Is it possible to save and load profile info in this plugin? Like player name, achievements, skill tree that carry over to next scene, etc...
     
  4. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Unfortunately no. The toolkit allows you to build self-contained tower-defense gameplay and levels. Anything extra like save/load, achievement are not included. You will have to build that yourself. The full source code is included so you should be able to do the modification.
     
  5. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Announcement: update version 3.0.1f1 is now live on AssetStore! :)
     
  6. Tashaf

    Tashaf

    Joined:
    Aug 5, 2014
    Posts:
    2
    NullReferenceException: Object reference not set to an instance of an object
    TDTK.PerkManager._PurchasePerk (TDTK.Perk perk, Boolean useRsc) (at Assets/TDTK/Scripts/PerkManager.cs:159)
    TDTK.PerkManager+<DelayPurchasePerk>c__Iterator11.MoveNext () (at Assets/TDTK/Scripts/PerkManager.cs:105)


    error when loading demo 7 plz help...
     
  7. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Have you delete any of the tower prefab without removing it from TowerEditor? Try open TowerEditor, that should help reset it. Then please try again. In the future, I would suggest you not to delete any tower prefab before removing it from TowerEditor.
     
  8. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    So I go to add a perk that gains a new abilitie, it added the ui and such to the bottom of the screen but when I click it it does nothing at all.. Any clue why its doing that? Also the same with any new tower I add I click it and it does nothing. All based off buying the perk for the new tower and new abi.
     
  9. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There used to be some issue with that but it has since been fixed. So are you using the latest version (last update 27th march)? I have to say while I come across some bug while testing with the abilities earlier, unlocking new tower and ability works just fine for me. The new buttons shows up and they work. If you are having problem with just the ability, perhaps you are experiencing the bug I just come across. Otherwise there no reason why they wouldn't work.
     
  10. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    That maybe it. I have an older version. I think. Is there a change log? I hate to have to update it an lose everything I worked for or will it be okay since my stuff is prefab from what I can see it seems like it just grabs the data from the prefabs.

    Is there any chance you can tell me what you did to make it work. Im afriad to update it and it mess up all the work Ive done.
     
    Last edited: Apr 17, 2015
  11. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Have you done any code modification of your own? If not, you can safely update the project. Just make sure you dont import the 'Resource' folder so your own setting wont get overwritten. At any rate, do make a backup before you update.

    If you have modified the scripts, I've afraid the the change is potentially not straight-forward. Truth is there might have been more than one fixed that concern the related code. And even I can't quite remember what exactly did I do. There two possible ways you could do this. The first, make a note of you own modification, update the package like normal and re-apply your own modification. The second, download the new version, trace the code and compare what changes has been made. If you decided to go for the second option, you can start at PerkManager.cs, in function PurchasePerk, look for line if(perk.type==_PerkType.NewTower) and if(perk.type==_PerkType.NewAbility). From there, you can check which function is called or not called, and if those function has any difference between the two version.

    I'm sorry I cant be any more help. I hope at least this makes it easier.
     
  12. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    I went ahead and just updated it without the resource file. All I really did was edit the UI and the menus and such. I had just a few extra things added. Which I went ahead and went back and changed it wasn't anything to major. But I love your system so much. Right now im adding leaderboards and a promo system that's giving me a headache. Overall you did a wonderful job. I love the instance I forgot all about that. Like how you implemented the UI and how you use the Hide class and such is so easy. Really nice job. How long have you been coding? What is your favorite programming language?
     
  13. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for your compliment. :)

    I've started coding probably 6 years or so ago. Taught myself mostly. I don't have a favorite coding language per se, only one that I'm most familiar with. I switch from time to time depend on what is required, often relearning most thing from scratch in the process. Atm, and this has been for a long time, I code almost exclusively in C#.
     
  14. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Its great man well done im in the process of learning how to code im a senior in college ive codded mainly in Java/C++ so moving to C# hasn't been to overwhelming but ive only been coding for a year or so and this is my second game ive ever coded. I still always have to go back and look for references. I loveee the namespace how I can reference from any class in that namespace I never knew you could do that its great, no its epic.

    On the other-hand I have a question for you. I see in your code for killing a creep the amount of gold you get.

    Code (CSharp):
    1. public float CreepDestroyed(){
    2.             List<int> rscGain=new List<int>();
    3.             for(int i=0; i<valueRscMin.Count; i++){
    4.                 rscGain.Add(Random.Range(valueRscMin[i], valueRscMax[i]));
    5.             }
    6.             ResourceManager.GainResource(rscGain, PerkManager.GetRscCreepKilled());
    I suppose the resources are all in a list. How do I go about just adding say 100 gold to the player. I tried to create a new list in another class that is using namespace as such:

    Code (CSharp):
    1. else if (values[0] == "OK")
    2.                     {
    3.                         this.state = State.OK;
    4.                         if (values.Length > 1) this.value = values[1];
    5.  
    6.                         if (value.Equals("Gold"))
    7.                         {
    8.                             amountofgold = 100;
    9.                             Debug.Log("Its A Go!");
    10.                             if (amountofgold == 100)
    11.                             {
    12.                                 List<int> rscGain = new List<int>();
    13.                                 rscGain.Add(amountofgold);
    14.                                 ResourceManager.GainResource(rscGain);
    15.                                 Debug.Log("Gold");
    16.                          
    The debugs are working great but it wont let me add the resource to the player. It has to be in a min.max? Im about to go search in the perk code see how that was written and see if I can add it like that. But anyway thoughts on this. Its bascially a promo code that if they put in gives them 100 gold for say.
     
  15. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    @songtan I bought this asset a couple of years ago and it really helped me out back then so thank you.

    I just noticed the models in the latest version look really nice and I wondered if it would be ok to use in my own project? (not a TDTK project)

    Would this be ok?

    thanks

    Nalin
     
  16. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    @Chaz32621, the code is alright. The question is how many resource type are there in your game? The length of the list you are passing in GainResource() must matches the total count of resource type in game. So if you have two resource type, you must have a list containing 2 elements. The order of the resource type in the list is as stated in the ResourceEditorWindow. Say if you have gold and wood in your game, the code needs to be
    Code (csharp):
    1. List<int> rscGain=new List<int>{ amountOfGold, amountOfWood };
    2. ResourceManager.GainResource(rscGain);


    @puzzlekings, of course it's ok to use the model in other game. Go ahead. Do send me a screen shot of your game when you are done. I would love to see how would you use them. :)
     
    Last edited: Jul 10, 2015
  17. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199

    Perfect man thanks! I completely forgot about the wood haha I'm leaving it at zero until i figure out what I'm going to do with it. May add it later on versions of the game im creating. Its a tower defense! However I didn't use your models tho using someone else.. Its my final game project for my undergrad class for my minor in game design. Id love to send you a version of my completed game so you can see how I implemented your code. I should be close to a beta in the next week or so.
     
  18. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Thank you :) and will do!
     
  19. Korok

    Korok

    Joined:
    Dec 19, 2011
    Posts:
    179
    I have just 1 small question: can I make a Plant vs Zombie clone with this kit? it seems possible but with your kit the enemies will avoid the towers and follow it path right? can I make them attack the towers too?
     
  20. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You can make levels with gameplay that more or less similar to Plant vs Zombie. The creep can be set to stop and attack tower when they come across one. That said, the framework doesn't cover all the game mechanic seen in a full PvZ game so you wont be able to make an exact clone of PvZ. You will have to do some modification of your own if you want to make an exact clone. I hope this answer your questions.
     
    Korok likes this.
  21. Korok

    Korok

    Joined:
    Dec 19, 2011
    Posts:
    179
    thanks for the fast response I'm gonna buy your kit and try
     
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Well thank you then. Please let me know if you have any further questions.
     
  23. Bombatit

    Bombatit

    Joined:
    Sep 4, 2013
    Posts:
    45
  24. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Try uncheck the "Apply Root Motion" option in the animator. The tutorial you are following are based on Unity4 so there's a small difference when you are using Unity5. This is something I discovered quite recently myself. Hope this help.
     
  25. Bombatit

    Bombatit

    Joined:
    Sep 4, 2013
    Posts:
    45
    tried, it's still the same
    i'm gonna try making another game object with other model from the beginning to see if there's any difference
    i'm using Unity 4.6 though
     
  26. Bombatit

    Bombatit

    Joined:
    Sep 4, 2013
    Posts:
    45
    Now it worked :D It's because I choose AnimatorRootObj = "- rootbone" it should be the 3rd child bone I post it here so if anyone have the same problem they can fix it. Your pack is really cool SongTan, well worth the money :D
     
  27. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Sorry for the slow respond. I went out for a while there. Glad it works now and many thanks for the compliment!
     
  28. Bombatit

    Bombatit

    Joined:
    Sep 4, 2013
    Posts:
    45
    I do search and read the document but still I have no clue :p can you tell me how do I make creeps always spawn and move along exactly at center of the path instead of randomly beside it?
     
  29. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It's simple, just set the "Dynamic Offset" value on the Path component to zero.
     
    Bombatit likes this.
  30. Bombatit

    Bombatit

    Joined:
    Sep 4, 2013
    Posts:
    45
    thanks for the fast response Songtan I thought it's somewhere in the spawn manager lol
     
  31. Bombatit

    Bombatit

    Joined:
    Sep 4, 2013
    Posts:
    45
    Hi SongTan I'm trying to add idle animation to towers, in UnitTowerAnimation.cs and UnitTower I added like this (the lines in the boxes are added):





    I have 2 errors:
    Assets/TDTK/Scripts/UnitTowerAnimation.cs(75,34): error CS1525: Unexpected symbol `!'
    Assets/TDTK/Scripts/UnitTowerAnimation.cs(106,1): error CS8025: Parsing error


    I'm an artist and really new with mecanim script (it's so different from Legacy you can't just call Animationplay to play animations, I'm drowning in those state machine mecanim script tutorials still have no clue) so honestly I have no idea what I'm doing :p Would you tell me am I in the right direction or not?

    Since it's simple please can you show me the needed codes to get Towers have Idle state. I think many other noob users like me (cos we can't code so we buy toolkits :p ) will really appreciate that and with your example I think I can add other animation states myself.
     
  32. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I was referring to legacy animation system so it's relatively more simple. However when it comes to mecanim, it's not something a few lines of code can do. Like what you said, you can just call a function to play certain animation. First you have to setup the state machine in the animator controller, only then you can control the flow of the state (each state plays a specific animation and you switch between state to play the animation you want).

    I cant really tell you the specific since it will depend on how you setup the state machine and what are the condition to switch between stage. I'm afraid that is something you have to rely on those mechanim tutorial. I doubt I can do a better job explaining it. But in term of the TDTK logic, you know when a tower is idle when it's not being built/upgraded or stunned and it hasn't got an active target, so the condition check should have been:

    Code (csharp):
    1. if(built && !stunned && target==null)
    Not sure why the && operator is missing back in the quote.

    Alternatively, what you can try is to use the default TowerAnimatorController, just set the idle state animation with your idle animation. Not sure how well that would work but it's the easiest way I can think of without going through a lot of setting and coding.[/CODE]
     
    Bombatit likes this.
  33. Bombatit

    Bombatit

    Joined:
    Sep 4, 2013
    Posts:
    45
    thanks for the advise SongTan, problem solved! Yeah using the TowerAnimationController works! I just have to duplicate it for each tower with different idle animations :D

    I have another question (sorry I'm so annoying), can I change the PlatformTD grid from squares to rectangles? where should I look at?
     
  34. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Are you referring to the individual tile in the grid or the grid as a whole?

    If it's the whole grid you are referring to, just adjust the scale of the platform object. If's the individual tiles you are talking about, I'm afraid there's no easy way to do that. You will have to change the way the grid is calculated and formatted. You can find most of them in BuildManager.cs. I wouldn't recommend it unless you are fairly familiar with coding.
     
  35. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Question for you man, I keep getting this error.

    Code (CSharp):
    1. ArgumentOutOfRangeException: Argument is out of range.
    2. Parameter name: index
    3. System.Collections.Generic.List`1[TDTK.UnityButton].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:635)
    4. TDTK.UIAbilityButton+<ButtonCDROutine>c__Iterator30.MoveNext () (at Assets/Code/TowerCode/UI/UIAbilityButton.cs:176)
    5. UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    6. TDTK.UIAbilityButton:OnAbilityActivated(Ability) (at Assets/Code/TowerCode/UI/UIAbilityButton.cs:173)
    7. TDTK.AbilityManager:ActivateAbility(Ability, Vector3, Unit) (at Assets/Code/TowerCode/AbilityManager.cs:252)
    8. TDTK.AbilityManager:SelectAbilityTarget() (at Assets/Code/TowerCode/AbilityManager.cs:180)
    9. TDTK.AbilityManager:Update() (at Assets/Code/TowerCode/AbilityManager.cs:110)

    What im doing that is causing this is I have a few new abilities that you have to buy as perks in order to use them. This maybe causing the problem? So once the perk is bought it adds it to your abilities and then ill go to click the spell and click it on tower or the terrian and then it crashes and I get this error. Any help?
     
  36. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm aware of that and have the fix ready. Please send me an email so I can send you the latest script package that contain the fix.
     
  37. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    @songtan thanks man sent it your way.
     
  38. Trevinburgh

    Trevinburgh

    Joined:
    Jan 26, 2015
    Posts:
    29
    Hi songtan. When creeps are navigating a platform, is there any way of forcing them to take 90 degree turns rather than cutting corners and going diagonally? I've tried looking at PathFinder.cs and NodeGenerator.cs but didn't understand them!
     
  39. Lorzor

    Lorzor

    Joined:
    Mar 23, 2015
    Posts:
    5
    Hy Songtan,

    My fellow programmer colleague is having trouble with the FPS mode.

    When we activate the FPS mode in game all the weapons attack but with 0 damage even if we assign from the editor X number of damage.

    Do you know what could be the issue here ?

    Thank you in advance
     
  40. Deleted User

    Deleted User

    Guest

    main menu does not work when i click.

    What should do now?
     
  41. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    Hi songtan,

    I apologize if these questions have been asked before (it's a huge thread).
    • Does this kit support creeps attacking the towers along the way instead of just trying to run past them?
    • Does this support creeps being on the same side as a player? Was thinking about setting up a tower defense multiplayer kind of thing.
     
  42. inthemilkywat

    inthemilkywat

    Joined:
    Dec 29, 2013
    Posts:
    56
    Does this kit support 2d?
     
  43. Idialot

    Idialot

    Joined:
    Dec 8, 2013
    Posts:
    18
    SongTan

    I am adding some extra functionality to the base game... basically, having my creeps reach a certain point, and steal resources from the player. I have this working fine, but I wish to end the game when the player resource stash reaches zero. I can't seem to find the script and method that I need to call to end the game. I wish to end the game and then load a game over stats screen that will then link back to the main menu to start a new game.

    Would appreciate some insight as to how to end the game when my parameters are met. Also need the script and method for ending the level as well.

    Thanks in advance
     
  44. Warlord4

    Warlord4

    Joined:
    Nov 26, 2012
    Posts:
    14
    Hello, SongTan!
    I have some problems with abilities. When i try to use some ability, i have such message "Invalid tagert for ability"!
    And there is no any error in the console!
     

    Attached Files:

  45. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    I get the same thing its because its on a mobile device I dont think all the code is 100 percent correct for the mobile version. Im trying to edit it myself. It looks like its under the Ability Manager.cs
     
  46. Warlord4

    Warlord4

    Joined:
    Nov 26, 2012
    Posts:
    14
    I tryed to check if it works through Unity Remote Control. So the abilities work fine! The problem is in mouse control. I think it will be fixed soon!
     
  47. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Well it runs fine if you do the PC version or Mac version. Its when the platform is that of mobile device that it isnt working correctly. Change you platform to pc it will work fine.
     
  48. Trevinburgh

    Trevinburgh

    Joined:
    Jan 26, 2015
    Posts:
    29
    I've put the first few levels of my TDTK game online as a Beta and would welcome any feedback. You can find it here:
    http://www.ignustor.com/beta/StreengeDefence/

    A couple of notes:
    - The Beta is web player only, final thing will also be PC & Mac stand alone. No plans for Android or iOS versions
    - I haven't done any optimisation yet. It's a 60Mb download and probably has way too many draw calls!
    - There's no high score table yet, I'm still thinking about the best way to implement this

    Thanks
     
  49. MrGky93

    MrGky93

    Joined:
    Feb 27, 2014
    Posts:
    281
    hi
    is it possible when example shoot it start in the animator a animation ??
     
  50. ActiveBaby

    ActiveBaby

    Joined:
    Mar 19, 2015
    Posts:
    1
    Hello. I cant change turret/creep model or add new unit. Can you check it?