Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

TowerDefense ToolKit 4

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

  1. MaxiMaximaal

    MaxiMaximaal

    Joined:
    Dec 7, 2019
    Posts:
    3
    You're both right, I got it working now! Using the default version of the TDUnitController and two empty separate gameobjects (with the tag/animator) for the model seems to be doing the trick. Many thanks @songtan @Niroan
     
    Niroan likes this.
  2. Sketchx

    Sketchx

    Joined:
    Jun 18, 2019
    Posts:
    1
    Hi, I'm new to this kit. i am trying to replace the tower prefabs in the tower editor with my own prefabs. When I select my own prefab it just reloads the sample prefab. It also wont let me add a new tower. Am I doing something wrong?
     
  3. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    Can you elaborate? What exactly did you do to replace the default prefab. What do you mean by selecting your own prefab? In game? Or checking which tower to use in TowerManager in Hierarchy tab?

    If you are not sure what you are doing and haven't gone through the documentation. I would suggest you to do that.
     
  4. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    52
    Sketchx create a new Gameobject.
    Insert Capsule Collider and then attach "Unit Tower" script from TDTK

    Make a Child Gameobject under that.
    Insert Mesh Filter and Mesh Renderer.

    Make and empty gameobject under that where you want you tower to shoot from.
    Then save as Prefab.

    Open Tools -> TDTK -> TowerEditor
    Drag the Prefab to the "Add New Tower: " then SAVE and edit name. Then save again. Close the Tower Editor and save your project. Then reopen Tower Editor and your tower should be available to place inside game :)

    Remember to Untick the "Hide in Inspector" inside the TowerEditor under the tower or the tower wont be able to be chosen inside game.

    Hope you get it working
     
  5. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    10
    Hello! First of all this asset is AMAZING!!! I will ask some help, but if its too much just say it please... Can U explain for the noobie like I am) (with example code it will be great) How can I add some perk resources like 5 -10 - 20 (I think its posible to do it with variable, for example after button click

    Again if it too much just say, anyway ur asset AMAZING)
     
  6. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    Thanks. Glad you like the assets.

    It's very simple to add perk resources. Just use this, PerkManager.GainRsc(valueGained).
     
  7. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    10
    Thank You it will be look like onbuttonclick PerkManager.GainRsc(valueGained) yeap?
     
  8. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    10
    Its work! Thank you very much!
     
  9. bastilar

    bastilar

    Joined:
    Apr 9, 2017
    Posts:
    17
    Awesome, thanks Songtan/Niroan.

    I did come up with an alternative solution but it still bugged out a little (not major) so I'l ltry your code.

     
  10. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    52
    I cant get the path to work if it make the path run the same path twice?
    Anyone made this work?

    I mean i get error if it have 2 path ontop of each other.
    My Path starts off.

    Then it goes to a square where i want the creeps to loop 2 times then exit of the loop and run on the third path to the exit. But somehow this makes the TDTK generate thousands of errors.
     
  11. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    It's hard to visualize your setup based on what you described. But I don't see why you can't loop a path or have 2 paths on top of each other. The only exception being there's platform in the path. obviously you can't stack 2 platforms on top of each other. I suspect you probably have some setting error in the way you set things up. Send me you scene. I'll have a look.
     
    Niroan likes this.
  12. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    52
    I send you private message with images. Can you please answer there?
     
  13. tree1895

    tree1895

    Joined:
    Mar 4, 2017
    Posts:
    1
    • I packaged the example to Android
     

    Attached Files:

    Niroan likes this.
  14. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    52
    Whats wrong?
     
  15. MasonWheeler

    MasonWheeler

    Joined:
    Apr 2, 2016
    Posts:
    148
    How to get this working with URP:

    1. Open a demo scene
    2. In the Hierarchy's search bar, type "t:Camera" to pull up a list of cameras.
    3. For every camera except the Main Camera, set its Render Type property to Overlay.
    4. For the Main Camera, add all the other cameras to its Stack list property.
    5. Run the standard Unity command to upgrade project materials. This will get most things but not everything.
    6. Unzip the attached file into \Assets\TDTK\Modular_SciFi_Asset_Set\Shader. It will add a custom shader named "Shader Graphs/BlendColorsOverlayTexture URP".
    7. Look through the subfolders of \Assets\TDTK\Modular_SciFi_Asset_Set for Materials folders containing unconverted (purple) materials. Switch the shader of all these unconverted materials to "Shader Graphs/BlendColorsOverlayTexture URP".
    8. Update materials for any objects in the scene that are still rendering as purple to the standard URP materials. They can be found in \Packages\Universal RP\Runtime\Materials.
    After this, it should be working.
     

    Attached Files:

    Last edited: Nov 9, 2020
  16. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    Thanks for the tip and the shader. I have no idea that there's a command to upgrade project material to URP.

    By the way to get everything to render properly, the camera stacking order should be as follow:
    • MainCamera (base)
    • OverlayCamera
    • UICamera
    • UICamera_Screen
     
  17. MasonWheeler

    MasonWheeler

    Joined:
    Apr 2, 2016
    Posts:
    148
    It only shows up if you're using URP, but yes, it's built in:

    upload_2020-11-9_15-42-23.png

    The first one will scan the entire project for upgradeable materials (ie. the ones using default shaders) and upgrade them. The second will upgrade all materials currently selected in the Project window.

    Anything using non-default shaders has to be upgraded manually. This is what my steps 6 and 7 do: I recreated the custom shader that ships with TDTK in Shader Graph for URP, and made sure all the inputs match so it works as a drop-in replacement.
     
  18. MasonWheeler

    MasonWheeler

    Joined:
    Apr 2, 2016
    Posts:
    148
    It doesn't appear to be possible to change the database files. There are context menu options to create new instances of the various files that go into the database, but because the architecture of TDTK works on static Instance fields which are loaded from hard-coded resource paths, creating these files seems kind of pointless since I can't set them as active.

    What's the right way to build a new database, without deleting or otherwise mutilating the demo DB that came with the package?
     
  19. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    The instance fields only get loaded and filled when you load the open an editor (window or inspector). You can force a reset if you just hit play and stop. All the static fields will get reset and need to be load again. Make sure you close all editor window and don't select anything that use a custom inspector (better yet don't select anything) when you do the reset. Hope this helps..
     
    Last edited: Nov 10, 2020
  20. MasonWheeler

    MasonWheeler

    Joined:
    Apr 2, 2016
    Posts:
    148
    Yes, and then they'll reload from the same hard-coded Resource path as before, and the new DB files won't be loaded.
     
  21. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    Sorry, I should have been more clear. You will need name your new DB files after the old one. You can rename the old files to something else if you want to keep them for backup. In my opinion there's really no need for that since you can always re-import them from the package you downloaded from AssetStore.

    The system is set up to use from one DB source. That why the paths are hardcoded. If for whatever reason you want to keep two or more set of DB files. You will either have to manually change the name so the system loads the right one, or you will have to modify the DB scripts to load from different DB files.
     
  22. gdp2

    gdp2

    Joined:
    Dec 6, 2016
    Posts:
    28
    Hi, I recently purchased the package and I'm having a little trouble. It seems I can't get Block or Mine Towers to build. I even tried building it in the builtin Simple Linear scene, but whenever I try to place the tower down, it says "Invalid Build Point". This only happens for Block Towers and Mine Towers. Everything else is able to build without a problem.
     
  23. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    Check your build-platform. Make sure those two towers are enabled on that platform. If you are not aware, you can enable/disabled certain tower on individual platform. I've disable block and mine on all the platforms in Demo_Linear scene (in fact in a lot of other platforms across all example scene). Those platforms are not walkable therefore placing mine or a block on them doesn't make sense.
     
    gdp2 likes this.
  24. gdp2

    gdp2

    Joined:
    Dec 6, 2016
    Posts:
    28
    Thanks so much! That was indeed the issue. I'm trying to add a grid right now which creeps can walk over, hence my curiosity.
     
  25. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    10
    Hello, Idk maybe someone already tell about that, but there is 3 question that I have...

    1) Then tower upgraded u can choose this tower and click again on upgrade button, if u do it tower will restart upgrade progress, take money but dont upgrade the level of the tower (for example I upgrade tower from 2LVL to 3LVL then i click it again in uprage state i lose money, tower start upgrade again but again from 2LVL to 3LVL)

    2) Is u will add the tower level to tower info then u click on it? it will be greate)

    3) Is it possible to preview the next wave creeps icons somethere? Like info about this wave to prepare for it)
     
  26. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    1. I believe I've fixed that in the latest update. Now you won't be able to upgrade the tower when it's being upgraded as the button won't be visible.

    2. I'll add that in the next update. For now you can add that by modify line184 of UITowerSelect.cs to this:
    Code (csharp):
    1. lbTowerName.text=sTower.unitName+" lvl-"+sTower.level;
    3. Unfortunately that is unsupported. I'll see if I can add that in the near future but please don't hold your breath.
     
  27. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    10
    Thank you so much!
     
  28. gdp2

    gdp2

    Joined:
    Dec 6, 2016
    Posts:
    28
    Hi Song, I have another question here. I made my scene based on the Simple Linear scene and now I'm having trouble getting my paths to go around a tower. This seems to work for other scenes, but not for this particular scene. When I create a grid in the path of the creeps, the path will not go around the tower. It just goes straight through it. Is there another setting not set on this scene?
     
  29. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    I take it by grid you mean a build platform. Have you assign it to the path as a waypoint? Just placing it in the path won't work.
     
  30. michealhahahaha

    michealhahahaha

    Joined:
    Sep 18, 2020
    Posts:
    1
    Great assets

    I just have some problems, maybe my own error but I can't figure out why. I somehow can't replace my own prefabs to the towers and spawns. It has no reaction to my operation...
     
  31. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    How do you replace those prefabs exactly? There are specific ways to do this. You need to add the prefabs to the DB before you can use them in game. I suggest you to go through the pdf documentation if you haven't already.
     
  32. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    10
    Hello) It's me again) I'm sorry for take ur time, but i find 2 more problems...

    1 Then I set Wave interval Min/Max in Spawn Editor its not working correctly (always have 5s between waves) (I have Generate On Start option turned ON)

    2 Idk maybe its not the problems but for me it is... When player win the lvl and NOT push continue button levelID is not increase but it should cuz Player win can u ask me how can I do it, but I'm really bad in c#


    Previosly u give me code line and code to solve my problem, if its possible I will be grateful)

    I'm trying to do


    if (highestLevelID>GameControl.levelID)
    {
    GameControl.highestLevelID += 1;
    }

    on Game Control 108line but unity sad that
    Assets\TDTK\Scripts\GameControl.cs(108,36): error CS0120: An object reference is required for the non-static field, method, or property 'GameControl.levelID'
     
    Last edited: Nov 19, 2020
  33. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    1. Thanks for letting me know. It's a bug. You can fix it by adding
    Code (csharp):
    1. wave.timeToNextWave=Random.Range(waveIntervalMin, waveIntervalMax);
    in Generate() in SpawnGenerator.cs. Anywhere after line49.


    2. Just change if(highestLevelID>GameControl.levelID) to if(highestLevelID>instance.levelID) should do the trick.
     
  34. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    10
    Yeap) looks like) I can't check is it work right now but unity error is gone) TY!
     
  35. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    10
    Hello Songtan!

    I have some problems with my project, so I need to transfer data base to new one, is it possible to transfer data base? if it is how can I do that?

    And second one is previosly one of the member ask about stats of towers in towers UI... I dont understand how he do it if there is some easy way can u explain how can i do it? Ofcours if its not so hard, cuz I'm bad in scripting
    ( https://forum.unity.com/threads/towerdefense-toolkit-4.132736/page-53#post-5808193 )

    Can you please help me with it
     
  36. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    All the data like perks and abilities are stored in the scriptable objects in Assets/TDTK/Resources/DB. The spawn information are stored on the SpawnManager in each individual scene. And of course yoru own custom tower and creep prefabs. If you want to transfer these to a new project, just export all of them into a unity package and import the package to the new project. See this link for reference.

    For your second question, there's a function Getstatsdescription() in Unit.cs that return a active value of stats in a list as string. So you can just go like this in your UI code:
    Code (csharp):
    1. public Unit targetUnit;
    2. public Text label;
    3.  
    4. void Update(){
    5.     label.text=targetUnit.Getstatsdescription();
    6. }
    The problem is the function currently only lists damage and attack cooldown. You will need to add more yourself. Shouldn't be very difficult. Just follow the existing format in the code.
     
  37. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    10
    TY! Cuz then i try to just replace my DB in new project just with CTRL C CTRL V its made too many errors in unity, TY again
     
  38. neapolitanstudios

    neapolitanstudios

    Joined:
    Feb 17, 2011
    Posts:
    50
    Hi Song,

    I'm experimenting with mazing using your platforms, and I'm struggling to get anything working with the stage pictured. Is this a limitation of your system? Or is there some way to make it work?

    To explain the image, the pipes are spawn points and the goal is the treasure chest. The bottom level is made up of several platforms, and there are waypoints that lead up the stairs to the platform under the treasure chest.

    I feel like I could make it work if the bottom was one big platform, however that creates issues with the platform on the raised section in the middle (where the goal is).

    Any ideas?

    Thanks!

     
  39. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,656
    I don't see why a raise platform on top of a bigger platform would be an issue? Can you explain what is the problem with that approach?
     
  40. neapolitanstudios

    neapolitanstudios

    Joined:
    Feb 17, 2011
    Posts:
    50
    I sorted out the issue with that approach. I didn't have colliders on the mesh, so the pathing didnt treat the area as an obstacle. I had to do some additional tweaks to waypoints to get it working, but it's flawless now. Thanks!
     
unityunity