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

TowerDefense ToolKit 4

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

  1. Geoffc

    Geoffc

    Joined:
    Feb 4, 2013
    Posts:
    39
    Yep, that is better. How can we change the 'Face Traveling Dir' to follow only the x transform? So it will still rotate along the X axis when the creep goes up/down or left/right along the path?

    GameObject unitObj=ObjectPoolManager.Spawn(creep.gameObject, path.GetSpawnPoint(), Quaternion.Euler(0, -90, 90)); is what I have there but that fixes the creep in this fixed x0, y-90, z90 rotation for the entie path journey.
     
  2. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    That is set in Creep.cs, Update(). Inside the if(faceTravelingDir...) section. Try adding this line - thisT.rotation*=Quaternion.Euler(0, 0, -90); at the very end of the section. I don't know about your settings so you might have to play with the value a bit to get the rotation right.
     
  3. Geoffc

    Geoffc

    Joined:
    Feb 4, 2013
    Posts:
    39
    Yep took a bit of playing with the angles. Now I have noticed the distance from the path is being calculated by Z (am I right?), where is that done, to change it to Y. I am talking about the Dynamic Offset for random creep positions from the path.
     
  4. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I'm not sure how well this will work but check last line of GetPathOffset() in UnitCreep.cs. Try moving the dir.z and dir.x around to change the offset axis to what you need.

    I have to ask, if there any reason you have to use the rotating the whole level around x-axis to use the xy-plane. You could just use a full top down camera angle to get the similar result.
     
  5. Geoffc

    Geoffc

    Joined:
    Feb 4, 2013
    Posts:
    39
    I am working with the camera in the orthographic mode for 2D with a tilemap for scenery. But you have made a good point, it may be easier to rotate the camera and the tilemap so the TDTK scripts are not changed.
     
  6. r4vvvne

    r4vvvne

    Joined:
    Mar 11, 2021
    Posts:
    1
    Hey, I really like your kit. Could you please help me with adding new creeps and using an animation. I would need a step by step manual. The infos I was able to gather from this forum and from the manual did not help me.. also not playing around with the example animated prefab. thx a lot! all the best
     
  7. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Try this:
    1. Create an empty object (this is the root-object), position it at (0, 0, 0)
    2. Add UnitCreep.cs to it
    3. Drag your model add it as the root-object's child (this is the mesh-object)
    4. Make sure the mesh-object is centered at (0, 0, 0) and it's facing z-axis
    5. Search through the mesh-object hierarchy, find an object with the component Animator (this is the animator-object)
    6. Drag TDTK/Animation/TDUnitController to the Controller slot in the Animator component
    7. Make this a prefab by dragging the root-object into the Project Tab.
    8. Add the prefab to the CreepEditor.
    9. In Animation Setting, assign the Animator Object (use the drop down and select the animator-object in step-5)
    10. Drag whatever animation clip you have for the model into each corresponding slot in the Animation Setting
    That should be it.
     
  8. RitsumeiWang

    RitsumeiWang

    Joined:
    Jun 7, 2021
    Posts:
    13
    Sorry for asking some questions when i redevelop the kit for my game
    As i know all the data (tower/creep etc.) is saved in like local xxxDB_Obsolete
    1.Now i have a cloud database for saving units' paras and i want to overwrite those paras on local db(or only use paras in game scene) with cloud data. where should i start from? any hint for the steps?
    2.Is there any possibility for users to change local units' paras through exported unity game files?
     
  9. Andrew203

    Andrew203

    Joined:
    Apr 23, 2018
    Posts:
    43
    Hey, is anyone having a problem where after updating toolkit to newest version you cant upgrade a tower?
    Standard towers from toolkit are working properly, but when I add mine to database where upgrading tower means replacing it with better one I have a upgrading button locked.
     
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    No problem at all. The DB are just a reference point to the unit-prefabs. The stats are actually stored on those prefab. If you have a cloud data and you want to use them, probably the best way to do it is override the prefab value with the cloud data when spawning the unit. For towers, look for CreateDragNDropTower() (if you are using drag n drop build mode) and BuildTower() in TowerManager.cs. Those are the two function call when towers are created in runtime. You should be able to get the tower instance and override the stats value. In fact, the functions are already doing that for some of the attributes on the tower instance, you just need to add the code for the stats you want to override. For creep, look for SpawnUnit() in SpawnManager.cs.
    As for 2, I'm not sure what you mean by exported unity game files? Can you explain?

    It's a bug. You can fix it by changing line 244 in UITowerSelect.cs to
    if(!TowerManager.CheckTowerCounterLimit(nextTower.GetTypeID(), nextTower.limitInScene)){.
    The original line is the missing exclamation mark.
     
  11. Andrew203

    Andrew203

    Joined:
    Apr 23, 2018
    Posts:
    43
    Works like a charm, thank you for quick answer.
     
  12. lionel_wang

    lionel_wang

    Joined:
    Oct 7, 2019
    Posts:
    2
    Hi, Thanks for your awesome TD Kit project.
    I am trying to make a TD game with 2D, is there any advice to make TDTK4 fits better with 2D?

    Thanks again~
     
  13. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    It depends on what kind of 2D you are referring to. Mostly it would fit just fine. The key here set the camera projection to orthographic and lock the camera rotation to the angle you want. For instance if you want a top down 2D, all you need is to make the camera look 90 degree down. The only problem is depend on the combination of camera angle and sprite assets that you are using (if you are using sprites), you will probably need to disable the default unit rotation and have your own solution to display the sprites correctly. There's some example code in TDTK/Scripts/Support_NotInUse.cs that do that. That's everything that comes to mind.
     
  14. RitsumeiWang

    RitsumeiWang

    Joined:
    Jun 7, 2021
    Posts:
    13
    Thanks for answering! That helps a lot
    for 2 what i actually want to say is that is there any possibility for users that they can overwrite data illegally since all data is saved locally.
    And here is another problem i met , not tech but about license
    Actually we have a team include 8 members. 3 designers 3 artists and 2 programmers.
    Only I am responsible for redeveloping the TDTK and another guy for server.
    So basically i am using the TDTK directly in editor mode, with code changes and new contents so on.
    However when building WEBGL or Android apps he will be touching the project.
    Is this ok for you since I bought with personal license(or so called Per Seat license)?
    Also if we found new programmer in future and push him to make new changes on the revised game version, it is possible for sharing the license since we are one single team?
     
  15. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    It's always possible when it's a self contained software. It's basically what game modding is.

    As for the licensing. If you all have your own login for your unity editor, there's no way for multiple user to share a license. Meaning you cannot allow other user access the your on AssetStore. That said, there no stopping you from transferring the project files between multiple user. So if you have a new coder, you can just copy and send him/her all the project files. Strictly speaking you all should have your own copy for TDTK, but there's no way to enforce that. And I don't really mind anyway. :)
     
  16. ceprowler

    ceprowler

    Joined:
    Oct 24, 2020
    Posts:
    18
    Song I have a question. I made an ability where a temporary turret is spawned for 20 seconds. However, after the ability timer runs out and the turret leaves the playfield any friendly area affects still target it at the position it was placed and if it is spawned near a turret placement point it will block other turrets from being placed in that area. I see the clone of the object being removed from my Hierarchy so I'm not sure why it is still blocking that area and receiving friendly affects. Any ideas on how to solve this issue? If it helps this ability is hostile with the on activation effect being the turret that is set to auto destroy after 20 seconds.
     
  17. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    How do you create and remove those temporary towers? To get a tower to work properly, you have to use the add the tower to TowerManager (using TowerManager.AddTower()) when creating it and remove it (using TowerManager.RemoveTower()) when destroying it.
     
  18. ceprowler

    ceprowler

    Joined:
    Oct 24, 2020
    Posts:
    18
    Well, I might have been overly creative this time. First, I made the turret in the turret editor. Second, in the ability editor I put the turret prefab in the "on active effect" with the time it was supposed to function. See photo below. It works great with the one exception being that even though it disappears from the Hierarchy (in the clones list) it still get effects and takes up space in the world for some reason. I'm unable to find a collider on it anywhere so I'm at a bit of a loss on what is getting left behind? I'm not really sure how to trigger the remove tower command when the timer runs out.
    upload_2021-11-23_20-58-24.png
     
  19. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Try this. I've upload a TowerSelfDestruct script. You will need to attach that to the 'SpaceShipWrapper' tower object. The script will automatically remove a tower properly after the duration specified. With that you no longer need to use the 'Auto Destroy' option on the 'On Activate Effect'.
     

    Attached Files:

  20. ceprowler

    ceprowler

    Joined:
    Oct 24, 2020
    Posts:
    18
    Works perfectly! Thank you for your help and the quick response!!!!
     
  21. threshold92

    threshold92

    Joined:
    Apr 14, 2018
    Posts:
    2
    Where can I find the official, step by step documentation, on how to use the asset (I have purchased it).
    I have watched some of the YouTube links, but it only gives a high level overview, and not step by step instructions.
     
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    There's a pdf documentation in the package that explain in greater detail how the framework works and how to get certain things done. But there's never an official step by step when it comes to using the asset. The framework is a bit like Unity itself. It's a set of tools that can be used to make tower defense level in many ways. Unless you have a very specific things that you want to achieve, it's a bit too open ended to do a step by step.
     
  23. threshold92

    threshold92

    Joined:
    Apr 14, 2018
    Posts:
    2
    Thanks so much - I found the PDF - it is exactly what I needed.
    Great asset by the way.
     
  24. Drewski66

    Drewski66

    Joined:
    Feb 12, 2016
    Posts:
    21
    Hey Songtan, I came back after a while to find so many updates and changes! You're doing an amazing job!

    I have a question regarding the damage table, or more accurately the tower editor, I'm doing a Rock, Paper, Scissors style game and I'd like to set my AoE tower to deal extra damage to a creep that hides in a mass of units. So far it seems on the Turret setting has the option to change it's damage type, is there a way to add that option to other tower types?

    Again I love the kit!
     
  25. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Glad you like it.

    It's an oversight from my part. AOE tower and mine should have got the damage type setting enabled. You can fix this by changing line 415 in _TDEditorWindow.cs to if(IsAbility(type) || turret || aoe || mine){ instead of just if(IsAbility(type) || turret){.
     
  26. Drewski66

    Drewski66

    Joined:
    Feb 12, 2016
    Posts:
    21
    Sounds good to me! Thanks Song!
     
  27. Drewski66

    Drewski66

    Joined:
    Feb 12, 2016
    Posts:
    21
    Hello Songtan, I have another question regarding TDTK. I have it set up that a tower levels up to 3 then can upgrade into a new tower based on perks. I have 5 potential towers they can upgrade into but only the first 3 work, towers 4 & 5 do not show up as an option once unlocked. I have a feeling it's because only 3 upgrades can fit in the UI, but the way I have this set up only 2 upgrade options will be available at a time. Do you have an idea how to solve this? I don't know enough yet to try and fix it alone lol
     
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    By default, the UI script only create 3 upgrade buttons. That's the reason why the fourth and fifth option for your tower doesn't show up. You can fix this by changing UITowerSelect, line-50, to for(int i=0; i<5; i++){. Note the change from 3 to 5.
     
  29. Drewski66

    Drewski66

    Joined:
    Feb 12, 2016
    Posts:
    21
    Works like a charm, thanks Song!
     
  30. Drewski66

    Drewski66

    Joined:
    Feb 12, 2016
    Posts:
    21
    Sorry to keep bothering, but I have 2 more questions.

    1. I can't get my support towers to buff other support towers, this includes support creeps buffing other support creeps. Is this intended? Or at least is there a way to change it?

    2. Out of curiosity for a potential game idea, how many levels for a tower do you think could support? Like could I get a tower to have somewhere around 100 levels?

    Thanks for your time!
     
  31. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    1. This is intentional to avoid any logic complication. Imagine a group of support tower that buff each other effective range. Things could quickly get out of hand. I'm afraid there's no easy way to change this. You will have to change the way the support tower is implemented entirely (code-wise) to get it to work properly.

    2. I haven't test it myself. But I think you should be fine with a 100 levels tower.
     
  32. Drewski66

    Drewski66

    Joined:
    Feb 12, 2016
    Posts:
    21
    Makes perfect sense, I'll just adjust my game design going forward.

    Sounds like a have something to test out lol

    Thanks gain!
     
  33. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Well. I have just done a quick test by giving the towers 100+ levels. Works just fine for me.
     
  34. culmastadm

    culmastadm

    Joined:
    Mar 5, 2020
    Posts:
    7
    Hello.

    How might I change the gear icon? I am using your kit in a fantasy setting.

    Thank you.
     
  35. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    You mean the second resource icon? Same place where you set the game starting resource. Look for the game-object named 'GameControl', you should find a RscManager on it. You can change everything about the resources there.
     
  36. RitsumeiWang

    RitsumeiWang

    Joined:
    Jun 7, 2021
    Posts:
    13
    Hello I met some other problems
    1.everything works well in editor mode with DragNDrop, but when things come to build as I clicked tower, game will not create a tower on mouse point to let me build it
    2. I tried to rotated Camera and in scene NodeIndicator preforms well but in display it looks wired as in the image
    Thanks!!!!!!!!
     

    Attached Files:

  37. RitsumeiWang

    RitsumeiWang

    Joined:
    Jun 7, 2021
    Posts:
    13
    I found that OverlayCamera can fix problem 2 but also no idea about problem 1
    and I also found that
    3.if the creep is marked as spawner it can correctly spawn sub-creeps but sub-creeps will not move even they have path on the object
     
  38. RitsumeiWang

    RitsumeiWang

    Joined:
    Jun 7, 2021
    Posts:
    13
    I check the build file log and found the null ref error and solve it
    it is wired because editor did not tell me the error, anyway it worked
    The only one left is 3...
    3.if the creep is marked as spawner it can correctly spawn sub-creeps but sub-creeps will not move even they have path on the object
     
    Last edited: Dec 28, 2021
  39. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    Do you see any error message for the sub-creeps? If not, have you checked their move speed? Please note that certain stats of the sub-creep is derived from the spawner itself, using the value in 'override setting' when you set the spawner.
     
  40. RitsumeiWang

    RitsumeiWang

    Joined:
    Jun 7, 2021
    Posts:
    13
    is that mean sub-creep speed is derived from the spawner current speed when it died?
     
  41. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    It means the sub-creep speed is derived from the spawner speed, when the sub-creep is spawned. However, this only applies if you have the override value set to something higher than 0.
     
  42. Drewski66

    Drewski66

    Joined:
    Feb 12, 2016
    Posts:
    21
    Hey Song, have you considered having Platforms that buff towers placed on them? I don't know how to even begin, but could it be added in the script to apply an effect to any tower placed on it? I wanted to add specific spots that could increase the range of towers built on them, like a high ground of sorts.
     
  43. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    I had but ultimately didn't pursue the idea. I thought it's going to be tricky integrate it to already established editor UI.

    Rethinking the idea now, I might have a solution. It's not going to be as tightly integrated as the rest of the system in term of UX, but at least it's there, and should be useful and flexible enough if you need it. Give me some time to try it out. Email me again in a few days just in case I forgot to get back to you.
     
  44. Drewski66

    Drewski66

    Joined:
    Feb 12, 2016
    Posts:
    21
    Sounds good to me!
     
  45. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    @Drewski66, I've just sent you an private message containing the idea we talk about.
     
  46. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    115
    Anyone in here figured out a way to change the build platform to something else?
    I want to have and particle effect instead of the mesh?

    Can anyone help me with this?
     
  47. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    That's not really possible. I would recommend just making the mesh invisible and adding your particle effect. Or I guess technically you don't need a mesh, only a collider.
     
    Niroan likes this.
  48. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    115
    So lets say i have 4x6 platform? How would i make the particle effect show then?
     
  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,990
    You cant change the build-platform to something else, but you can definitely change it visually. It's just like @toddkc said, what you need is just the collider. So you can disable the MeshRenderer component on the build-platform and replace it with something you want.

    If you have a 4x6 platform and you want the each tile on the platform to be an individual particle effect, just place those particle effects transform as the child of the platform, and position them at where the tiles would be. See the image attached.
     

    Attached Files:

    Niroan likes this.
  50. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    115
    Is there some fancy way to get the grid to align perfect?