Search Unity

TowerDefense ToolKit 4

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

  1. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    Just logged in to the store to get linked back here to see if there was a reply, and noticed V4 was on sale for $15 so of course I bought it. If you did that thanks, it was definitely not that price last night when I posted.
     
  2. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It wasn't on sale. :)

    You should know that if you have own previous version, you don't need to pay the full price, just $15 for the upgrade. You probably didn't log in before so it showed you the full price.
     
    toddkc likes this.
  3. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    I did not know that. I asked you about that before and you said it wasn't possible so I didn't realize I could get it for $15. That's just fantastic.
     
  4. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    I LOVE how the ui is decoupled from the game logic in v4. I'm porting this over to VR and basically all I am having to do is make a new world space ui, none of the game code needs to be changed.
     
  5. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    @songtan is there a way to have the preview/sample towers be a different prefab than the final built tower? I'd like to have the towers look different before they are actual towers.
     
  6. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Not by default I'm afraid. But I suppose you can do a little modification to support that if you are so inclined. You simply need separate the tower prefab hierarchy into preview and built and have UnitTower activate one and deactivate the other depend on the circumstances (The preview would be active and visible for sample towers and built for actual built tower). Hope that make sense.
     
  7. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    Makes perfect sense, thanks. I just wanted to verify I wasn't missing it somewhere. I have it working with the 'Point N Build' setup, but haven't got the 'Drag N Drop' working quite yet.
     
  8. Jon_Brant

    Jon_Brant

    Joined:
    Mar 22, 2018
    Posts:
    56
    Hey there, noticed a bug. I'm using Unity 2019.3.0f6, freshly downloaded/updated TDTK, when I add units to the creep database, and go to add them in the spawn editor, it won't let me add the last creep I added to the database. If I add another creep, it will let me add the creep I was previously unable to add, but then I can't add the new one.

    Here's a video of how to reproduce it:
     
    Last edited: Feb 23, 2020
  9. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks for bring this to my attention. My guess is the editor hasn't update the selectable creep list in SpawnEditor when you switch over the SpawnEditor after you added the creep. I'll see if I can fix it. In the mean time, you can force it to update by start playing and stop the scene (any scene). Or simply just make sure you have add the creeps to CreepEditor, force it to update, before you start editing the SpawnManager.
     
  10. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    Hey bud!
    I have another one of my crazy questions:
    Currently the game gives a setable amount of perk points when the user wins the game. I would like to change that in a way that the amount of perk points depends on the amount of lives left at the end of the level. Where would be the best place to implement that in the code?
    Thanks!
     
  11. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    GameControl.cs
    has a function
    EndGame()
    . If the player wins that will call
    GainRsc()
    from
    PerkManager.cs
    .

    You will want to edit the value sent to
    GainRsc
    . It defaults to
    instance.perkRscGainOnWin
    , which is the value you can set in the inspector. If it were me, I would use that value as a max and figure out what percentage to give based on the remaining health.
     
  12. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    That sounds great! I will try that! Thanks!
     
  13. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    @toddkc, thanks for answer the question for me! :)
     
  14. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    You are welcome. Hope I'm not stepping on your toes, just trying to get more discussion going between us users :D
     
  15. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Of course not! I really appreciate the help.
     
  16. Jon_Brant

    Jon_Brant

    Joined:
    Mar 22, 2018
    Posts:
    56
    Is there any way to disable object pooling? It's really messing up my VFX D:
     
  17. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Just sent you a package containing the modified script that has the pooling disabled.
     
  18. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    How do you set the price of block type towers? I can't seem to do it in the tower editor menu, and I figured I'd ask before digging into the editor code.
     

    Attached Files:

  19. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    My bad. It's a bug that cause it to not showing. I've just sent you a fix.
     
    UlfvonEschlauer and toddkc like this.
  20. Jon_Brant

    Jon_Brant

    Joined:
    Mar 22, 2018
    Posts:
    56
    Hey there, is there a way to set a delay on an ability's effect? I have some effects with a "wind up" that displays effects at the start, but the actual "hit" effect takes a second. I thought I saw this in the ability settings before, but can't find it now.
     
  21. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It's 'Effect Delay'. Just after 'Effect Type'.
     
  22. Jon_Brant

    Jon_Brant

    Joined:
    Mar 22, 2018
    Posts:
    56
    Derrrp, thanks. Thought I saw it somewhere.
     
  23. matzomat

    matzomat

    Joined:
    Mar 4, 2018
    Posts:
    63
    Best money spent on asset yet! Thank you for all your work @songtan

    I have 3 questions:
    1. I would really speed up the workflow if adding a level to a tower in the Tower Editor could always clone the last level (use last levels values).
    2. I noticed that in Game towers keep their HitPoints after upgrade, even if the new HitPoints are set to be higher. The max amount increases but I need to heal the tower to bring it to the new max. What am I doing wrong?
    3. I noticed that rockets that are left after an enemy is destroyed have a different targeting priority. They seem to attack someone near the start on many occasions.
     
  24. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thank you!

    1. and 2. is an oversight on my end.
    3. is a bug.

    I'll try to get all these fixed and get back to you asap.
     
    matzomat likes this.
  25. Jon_Brant

    Jon_Brant

    Joined:
    Mar 22, 2018
    Posts:
    56
    Could you check to make sure the tower OnBuilt sound efffect is working? It's not for me, not sure if I'm just doing something wrong. The other SFX seem to be working though, so I'm thinking it's bugged.

    Also, is there any way to play an effect when AoE towers affect an enemy? I'd like to spawn an effect to indicate the enemy is slowed. Or just effects in general, like a bleed effect for damage over time, etc
    Thanks
     
    Last edited: Mar 2, 2020
  26. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There's no OnBuilt. But there's BuildStart and BuildComplete. Both are working as far as I can tell.
     
  27. Jon_Brant

    Jon_Brant

    Joined:
    Mar 22, 2018
    Posts:
    56
    Whoops, sorry, used the wrong name. Not working for me. Will double check.

    What about the AoE tower effect though?

    Edit: Double checked, here's how I'm adding it, in case I'm having another derp moment:
     
    Last edited: Mar 2, 2020
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Ah. I see now you are referring to the one on tower prefab, not the event sound on AudioManager. I'll get that fixed.

    There's no visual indicator for effect yet. I'll see if I can get that added.
     
    Jon_Brant likes this.
  29. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    Can you please post the fix here? I have the same problem and I don't want to update my version of TDTK, because I made so many changes to the various scripts from our previous conversations. Would be cool, if you could add these features, btw, then I could keep my TDTK up to date(PM me, if you would like me to send you my versions of the scripts).
     
  30. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    Also have another question.
    I made a Main Menu Scene that essentially offers a screen for the user to load a specific level (or replay it) and purchase perks. I set my nextLevelName and mainMenuName to this scene (since I want to bring up the screen once the user has completed or quit playing a level.
    I can load my scenes from that menu scene just fine and they play through, but once the last wave is cleared, I get an error message:
    "NullReferenceException: Object reference not set to an instance of an object
    TDTK.UIHUD.UpdatePerkRscDisplay (System.Int32 value) (at Assets/TDTK/Scripts/UI/UIHUD.cs:172)
    TDTK.TDTK.OnPerkRscChanged (System.Int32 rsc) (at Assets/TDTK/Scripts/TDTK.cs:66)
    TDTK.PerkManager.GainRsc (System.Int32 value) (at Assets/TDTK/Scripts/PerkManager.cs:30)
    TDTK.GameControl.EndGame () (at Assets/TDTK/Scripts/GameControl.cs:115)
    TDTK.SpawnManager._CreepDestroyed (TDTK.UnitCreep creep, System.Boolean reachDest) (at Assets/TDTK/Scripts/SpawnManager.cs:324)
    TDTK.SpawnManager.CreepDestroyed (TDTK.UnitCreep creep, System.Boolean reachDest) (at Assets/TDTK/Scripts/SpawnManager.cs:292)
    TDTK.UnitCreep.Destroyed (System.Boolean spawnEffDestroyed) (at Assets/TDTK/Scripts/UnitCreep.cs:662)
    TDTK.Unit.ApplyAttack (TDTK.AttackInfo aInfo) (at Assets/TDTK/Scripts/Unit.cs:460)
    TDTK.ShootObject.Hit (UnityEngine.Vector3 hitPos) (at Assets/TDTK/Scripts/ShootObject.cs:276)
    TDTK.ShootObject.Update () (at Assets/TDTK/Scripts/ShootObject.cs:204)

    Do you have any idea what could be causing that?
     
  31. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    This probably has nothing to do with the menu and loading. Assume you haven't modify UIHUD.cs, and you are using the default UI, you must have accidentally delete the UI element that displaying the perk resource. Or if you are using your own UI, you haven't assigned the Text element.

    Btw I have sent you the fix for the editor bug where you can't edit block tower cost.
     
  32. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    Thanks for the quick reply as usual.
    I did not delete any UI elements (because I noticed that that causes issues). I had it disabled, but re-enabling it does not seem to fix the problem either. I tried that already...
    The thing is, it has not even loaded the Menu Scene yet (it is still in the original scene).
    Can you explain to me what exactly your code is trying to do at the end of the level?
    What object is exactly (not) referenced there (and where is that in the editor UI and where in the code)?
    Edit:
    It does not seem to be related to my Menu Scene. I get the same problem, when I replace the nextLevelName and mainMenuName with simply the next scene in the game.

    Edit: One thing that I did, is I at some point replaced the "Parts" resource with a "Reputation" resource.
    Does it expect something named "Parts" somewhere in the code as a hard coded resource name??
     
    Last edited: Mar 2, 2020
  33. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    Just skimming over this, but do you have all the necessary scenes in your build settings @UlfvonEschlauer ?
     
  34. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    Yes, I do. The Menu Scene is loading the two other scenes just fine. But once the game scene is played through. I get that error. I am not sure why that is. Admittedly, that error could have been there for a while without me noticing. I was focused on other things for a bit and might have missed it...
     
  35. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    I gotta agree with Song. After going through that error it does seem like the only missing thing has to be
    perkRscItem.lbMain.text
    from the UIHUD.
     
  36. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    Thing is that I even get that error when I do not load the menu, but simply another version of the same game scene.
     
  37. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    I just tried with a new project and I was able to reproduce this. It happens when towers are firing as the wave ends. It did not stop me from loading the next scene however.
     
  38. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    This is not from loading. As the log indicate the error originate from a shoot-object hit event, killing the last creep in game which trigger the game over function call, which in turn granting you more perk-point, which prompt the UI to update the display. Since the UI element is not there, you got a null reference.

    Check your UIHUD in the scene. In the script component UIHUD in the inspector, there should be a perkRscItem where you assign a game-object. Now this is a custom UI class that require an Image and Text component to displaying an icon and text. The code will look through it's hierarchy to auto-assign the Image and Text component. The key here is the game-object containing the Text component needs to be named "Text". If you haven't remove the link, you must have renamed the text object to something else.
     
  39. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    It does for me :(
    I also get (occasionally) a warning that the resources in the resource list don't match or something like that.
    I am wondering whether there is something off about the way I am handling perks and perks resources in my scenes now. I have replaced the part with a resource called "reputation". There also seems to be a separate perks resource.
    I am not exactly sure how that is handled differently from the other resources.
     
  40. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    Change line 191 of
    ShootObject.cs
    to
    if(tgtUnit == null || tgtUnit.IsDestroyed()) tgtUnit=null;
    to fix. Since your error says 204 I assume it won't be line 191 for you, but you should see the
    tgtUnit.IsDestroyed()
    line at the top of update, just add the null check there.
     
    Proto-G likes this.
  41. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    I think I figured it out!
    So, at some point I removed the "Parts" Resource, since I figured I would not need it. That caused a bunch of problems though and I got errors. So re- added a resource called "Reputation" to use for purchasing Perks. That must have had some really strange effect downhill because that resource is not actually showing up in the UIHUD when the game does not play. The PerkRscItem is still there at that point. However, when I play the game, there is a new entry in the UIHUD called Resource (with Image and Value) and the PerkRscItem entry disappears (gets disabled) instead. Since I chose the same symbol and values for both (I really got confused by all that, I guess). I never noticed. Now the question is, why does the PerkRscItem in the menu disappear at runtime? Can I do without it? Technically I really just need Reputation Resource for purchasing my Perks.
     
    Last edited: Mar 2, 2020
  42. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Question: Have you enabled 'Use RscManager For Cost' in PerkManager? If you have done that, you are basically ditching perk point and using the resource in your RscManager to unlock perk instead. That's why PerkRscItem get disabled during runtime. And since you are not using perk-point, the perk-point display (PerkRscItem) never got initiated to have it's text component assigned.

    Now you can easily fix your current error by replacing line172 of UIHUD.cs to:

    if(perkRscItem.lbMain.text!=null) perkRscItem.lbMain.text=value.ToString();

    Assume you never intended to use PerkRscGainOnWin (on GameControl) to modify the resource used for unlocking perk, that's all you need to do.
     
  43. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    Thanks for the explanation. I finally understand the resources, I think :)
    The issue was (for posterity) that the PerkRscGainOnWin had to be set to 0...
    The line of code from songtan also helped :)
     
  44. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    I just noticed that in UnitTower.cs, in the Sell function, you have
    effectBuilding.Spawn
    . I assume this should be changed to
    effectSold.Spawn
    . Easy change on my end, just wanted to let you know as well!
     
  45. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    Hmm, I can't seem to find that line of code in ShootObject.cs...
     
    timerift609 likes this.
  46. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    I have another question. I am trying to carry over my resources to the next level, but I don't see it getting carried over. The next level still starts at 0 for the my Reputation resource (which is the second one in the resource list, of that matters in any way).
     
  47. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    @UlfvonEschlauer I don't know if this helps you any, but my advice.....I too have modified a lot of the code in this project. So I always have an unedited version of it ready to look at when my changes break something. That line you can't find is in the file, unless you removed it. And the resources carrying over does work....unless you changed something to make it not work. I know that doesn't help solve your problem, but I definitely recommend keeping copies of the original scripts so you can look back at the working version when yours no longer does.
     
    Proto-G likes this.
  48. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    I know and I of course still have them. I haven't changed anything about this in Gamecontrol though and ShootObject.cs is still the same as it is in my backups (and does not have that line in it either).
    Is there something I need to watch out for with the carryover? E.g. does it only work in an actual build and not the Editor or something like that?
     
  49. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    It just occurred to me that maybe we have different versions of the asset. I am using the most recent update of version 4. Sorry for my assumption that you are using the same... I can't help with the resource carryover however, I am not using it.
     
  50. UlfvonEschlauer

    UlfvonEschlauer

    Joined:
    Dec 3, 2014
    Posts:
    127
    Yeah, I have not updated in a while, since I modified the code quite a bit (extra animations, dynamic scenarios with appearing/disappearing obstacles, etc).