Search Unity

TowerDefense ToolKit 4

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

  1. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    Well, if you just want to auto save the perk, the easiest way would be just add this function in PerkManager.cs

    Well, Thank You. Where and what to add to PerkManager.cs ?

    Thanks for your help. Sorry for my English
     
  2. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Like I said, Just add this function anywhere in the PerkManager.cs
    Code (csharp):
    1.        void OnDisable(){
    2.            TDSave.SavePerk();
    3.        }
     
  3. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    Thanks. It doesn't work. No errors. No Load. Scripts look like this
     

    Attached Files:

  4. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    so, too, does not work screenshot
     

    Attached Files:

  5. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    In TDSave.cs, try change the line

    List<int> perkList=PerkManager.GetCachedPurchasedIDList();

    to

    List<int> perkList=PerkManager.GetPurchasedPrefabIDList();
    By the way, putting TDSave.SavePerk() in Start() will not work. Start() is call during the start of the level, where the player hasn't purchase any perk. So it won't make any difference.
     
  6. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    Thanks. Now work.
     
  7. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    What would be reason for this error to be thrown?

    Debug.LogWarning("Error? Wave already cleared?");

    For some strange reason this error is thrown and the wave ends even when there is still an active unit alive. I cant figure out why it is even doing this. As it shouldnt if not all the units have cleared. Is there a way I can put another check before it clears the wave?

    Thanks as always!
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Can you reliablely replicate the error? Also when is the last time you update tdtk? I remember fixing a bug related to this a few update back. Try do an update to see if that fix the problem.
     
  9. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Its off the 4.0 branch. I will look at recent and see if theres any changes I sorta got passed that part I added a new condition with active unit count also == 0.

    I need a explanation to the sub spawning.

    I get to a point now where subspawning does not equal 0 so it never finishes spawning the wave.

    I added a wait for so the creeps spawn slowly instead of all at once, which im not sure why there all spawning at once.


    subSpawning = wave.subWaveList.Count;
    for (int i = 0; i < subSpawning; i++)
    {
    StartCoroutine(SpawnSubWave(wave, i));
    yield return new WaitForSeconds(1f);
    }

    while (subSpawning > 0) yield return null;


    But now it is not finishing the wave. Is there a certain time limit that the subwave should spawn at? Is the subwave spawned the same as the actual wave is? I guess a better understanding of what the subwave is. I only have one path. Do I need subwave? I want different type of creeps and it seems the only way I can get this to happen is by having a subwave.

    Thanks Song, not sure if you remember me but Ive been working on this project for a few years now and almost done it! Hopefully.
     
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Subwave is there for when you need to spawn different type of creeps in a single wave. It also allows you play with the timing of the spaw. You don't need to modify the code at all for what you need. Just adjust the value of delay in each subwave if you want them to wait. Say the first subwave needs 10sec to spawn, so you set the delay of second subwave to 12. Then it will start spawning 2sec after the first has done spawning. Make sense?
     
    Last edited: Apr 19, 2018
  11. primarygod

    primarygod

    Joined:
    Jan 16, 2017
    Posts:
    9
    hello
    I need some help. I was building my own towers when I accidently deleted the prefab of my tower. Now this tower is stuck in the DB without prefab. Tower Editor is broken and I can't delete it the standrard way. Can you hint me how to remove the tower from the DB.
     
  12. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Try this:

    1. Play. (Any scene will do, even an empty one)
    2. While In play mode, close the TowerEditor.
    3. Stop the play.
    4. Open the TowerEditor again.

    This should prompt the editor get rid of the deleted prefab automatically.
     
  13. primarygod

    primarygod

    Joined:
    Jan 16, 2017
    Posts:
    9
    thanks for the tip songtan but this didn't help. Let me repeat the steps I did exactly.
    1. Open the TowerEdtor
    2. Play
    3. While in play mode, close the TowerEditor
    4. Stop the play
    5. Open the TowerEditor Again

    Tower editor is still completely empty altho I can see I have all other default towers (from the toolkit).

    Edit: You can give me also codes to run to remove the tower from the DB I am a developer (just don't wanna spend too much time on what it seems to be not a big problem).
     
    Last edited: Apr 19, 2018
  14. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Right. In that case you will need to look in the folder Resources/DB_TDTK. Select the prefab TowerDB. You should see the tower list with one element missing (The one you deleted). Try to remove that element.

    I'm not sure what's the best way to do this without messing up the whole list. You probably need to create a new prefab and manually assign it to that slot then remove it afterwards using TowerEditor.

    If you haven't modify the tower list much and don't mind reassign your custom tower. You can just clear the list and start over. Or simply just reimport the prefab again.
     
  15. primarygod

    primarygod

    Joined:
    Jan 16, 2017
    Posts:
    9
    thousand thanks songtan, if I knew for the existing of this file I would never contact you. Everything works perfect now, ready to create new towers again :)
    (note: I saw in the bottom of the file the tower list and I saw in there not one but two items like {fileID: 0} so I removed them)
     
  16. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Got it sir thank you, I still wouldn't mind seeing you implement a boss wave spawn system :) Dedicated directly to spawning bosses.
     
  17. sala3000

    sala3000

    Joined:
    Jan 15, 2018
    Posts:
    8
    Hey Songtan,

    So I've been playing around with your code and I'm loving it! But there are still some things I don't fully grasp.

    For example, do I have to put a platform between each waypoint in the waypoint list? If I don't the creeps go through the towers (no collide) and if I do the path is weird. Look at this screenshot, there are 3 waypoints but the creep path is not the shortest, sometimes it's even worse.
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You don't have to put a platform between every waypoint. You only need to if you want the creep to move across that platform and avoiding towers on it. Based on your screenshot, I take it you want your creep to only move strictly on the platform but following the order of the waypoints? In that case, you will have to assign the platform as a waypoint between all the waypoints.

    I don't understand why you say the path is not the shortest. The screenshot shows the shortest path from waypoint1 to waypoint2 and then to waypoint3.
     
  19. sala3000

    sala3000

    Joined:
    Jan 15, 2018
    Posts:
    8
    Thanks for the prompt answer, okay got it for the plaform. I had some doubts since the path is weird.

    Look at this example it is more visual, you can clearly see on the first picture the path is not the shortest at all, I drew the shortest beneath, or at least a shorter one.

    The map in the example is plain empty, no blockers no anything, just the 3 waypoints.
     
  20. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I see. The tiles on the platform are not connected diagonally. So the path-finding algorithm return the shortest path without any diagonal connection. The diagonal section that you see is the result of the path smoothing. So it's the shortest path. Unfortunately the path smoothing algorithm doesn't work to your expectation all the time. I'll review the code to see if I can improve it. But please understand I can't promise I can fix this specific issue. It's quite a finicky things to get it working perfectly in all situation.
     
  21. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    @songtan

    Quick question, I keep getting all my copied units prefab id as -1. Where is the code that copies the prefab, for some strange reason its not copying over the id. Need it set to the actual prefab id.
     
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    How do you copy your prefab? Manually (using ctrl+c) or via some code? Fyi, the value of prefabID for all unit are default at -1.
     
  23. sala3000

    sala3000

    Joined:
    Jan 15, 2018
    Posts:
    8
    Well for a competitive TD game this is a big issue..

    The main point of a TD asset is a good pathfinding. Perks & co are bonus and not the core of a TD. Instead of adding specific features as perks which are useful for a handful of people and not that hard to code maybe you should fix core problems, the path on the second screenshot is really a joke. So you spend time adding multiple path but don't fix the broken path finding????

    I'm really disapointed with your asset and I just started using it, so the only solution for me is either drop your asset or fix it myself since it seems you won't fix it, in either cases buying this was a waste of money and time.

    Quite a shame that a 50€ tower defense asset can't even get path finding right while it is one of the core features of a TD. I can't even imagine what the result will be with a bigger map, more towers and blockers.... You realise this is the simplest map ever? Just loaded the default stuff from your asset, no modifications, and it's already broken.

    I will still try and find a way to make this asset useful but if I can't I'll have to leave a very bad review for the money and the time you took from me.
     
  24. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm sorry that you think this way. I've made a lot of effort to make sure everything works before releasing it. I've used the framework for my own released game without any problem (including path-finding). Admittedly I'm not aware that the discrepancies are an issue for some user. To say that it's outright broken is harsh. Beside I'm not saying that I'm not going to do anything. Just don't want to make empty promises since I don't have a solution readily available.

    By the way, I've been looking at the code since your last post and might have just found the solution. I'll post an update in due time. If you are still planning to use the framework, please send me an email so I can send you the finished tweak in advance.
     
    Chaz32621 likes this.
  25. sala3000

    sala3000

    Joined:
    Jan 15, 2018
    Posts:
    8
    Well if you rely on path finding, it is broken. In any competitive game players would complaint instantly so yea it's a big issue, and pathfinding is a core feature of TD. But yea your asset is still top quality, I can see the work that has been put into it, that is why I won't put a bad review and still try to get my way around it.

    I'm not in a rush so I can wait for a fix but I need to know if there will be one because if not I may consider moving to another TD/pathfinding asset and most of my work on TDTK would be lost.
     
  26. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'll try to do an update before the end of the week.
     
  27. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Sorry I should have been more precise. So when i create a unit in the creep editior the unit prefabid is set to 1 and so on plus plus. But when the unit is spawned by the spawnmanger/generator the unit creep which is a clone of the prefab, that prefab id is -1.
     
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I think I know what you are referring to. It's a harmeless bug. When a unit (both creep and tower) is selected in the editor (not in game), the script for the inspector editor will check if it's connected to a prefab or not. And if not, it reset it prefabID to -1. The unit spawned during runtime is not connected to the prefab so the prefabID will be reset to -1 if you select them in hierarchy. However this only happen if you select the unit. So by default, they will retain their prefabID.

    I'll fix this in the next update. For now, you can just ignore it. Things should be fine as long as you don't select your unit in Hierarchy Tab.
     
  29. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Got it could you shoot me a fix for it whenever no rush, theirs something i'm adding on my side of code based off the unit prefabid of the clones.I have modified your template quite a bit. (If you need proof Ive purchased it I can)

    Also I was going through the Spawn Code. And ran into this little bit. I'm working on creating a duplicate spawner system for boss waves. While going through it I seen this few lines of code. (Not sure if you fixed this) but

    This is under ur W_SpawnEditor.cs, its the public float DranGeneratorParameter(float startx,float starty)

    I would give you the line code for it but Ive modified the code so much on myside not sure if its in the exact same location.

    Code (CSharp):
    1. //cachedY=startY+spaceY;    cachedX=startX;
    2.             for (int i = 0; i < gen.attRscGainOnCleared.Count; i++)
    3.             {
    4.                 DrawGenAttribute(startX, cachedY, gen.attRscGainOnCleared[i], RscDB.GetName(i), "", RscDB.GetIcon(i));
    5.                 startX += genAttBlockWidth + 10;
    6.             }
    7.             DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Perk Rsc Gain:", "", PerkDB.GetRscIcon()); startX += genAttBlockWidth + 10;
    8.             DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Ability Rsc Gain:", "", AbilityDB.GetRscIcon()); startX += genAttBlockWidth + 10;
    9.  
    10.             startY += genAttBlockHeight + spaceY * 2; startX = cachedX;
    11.  
    12.             for (int i = 0; i < gen.genItemList.Count; i++)
    13.             {
    14.                 if (gen.genItemList[i].prefab == null)
    15.                 {
    16.                     gen.genItemList.RemoveAt(i); i -= 1;
    17.                     continue;
    18.                 }
    19.                 startY = DrawGenItem(startX, startY, gen.genItemList[i]) + 10;
    20.             }
    Should it not be:

    Code (CSharp):
    1.  DrawGenAttribute(startX, cachedY, gen.attPerkRscGainOnCleared, "Perk Rsc Gain:", "", PerkDB.GetRscIcon()); startX += genAttBlockWidth + 10;
    2.             DrawGenAttribute(startX, cachedY, gen.attAbilityRscGainOnCleared, "Ability Rsc Gain:", "", AbilityDB.GetRscIcon()); startX += genAttBlockWidth + 10;
    Sorry if you have already corrected it, I have not done the last update off the 4.0 branch.
     
  30. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You are right. Good spot! I'm not aware of this. Thanks for pointing this out.
     
  31. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Anytime :) there was another small minor issue I think in the perks, but since you updated that in the last version you might have gotten it. If I stumble into it again ill send it your way.

    Ive built a whole boss system with its own unique wave id from the original spawn system. If you'd like to see the final product(game) let me know should be finished in about three months hahaha. Going to add a mini boss wave system and a bonus wave system. So much I wanna add. But its a mobile game gotta keep the data low.
     
  32. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Its for sure well worth the money, if you took some time and just went through the code and modified the things you dont like you would really better yourself and learn more coding at the same time.
     
  33. sala3000

    sala3000

    Joined:
    Jan 15, 2018
    Posts:
    8
    Pathfinding is a core feature of a TD and the main point of me buying this, what's the point of buying an asset if you need to recode everything, you'd be better off starting from scratch. The main point is to bootstrap your dev not slow it down and recode the whole thing, already got plenty of code to do ahead. And I don't know if you're aware but getting pathfinding right is not an easy task as adding a "boss" wave and is time consuming.

    There are a lot of pathfinding assets, I have chosen this one and I expect it to work. This is not something I don't like, it is a CORE feature, I would prefer having less of the superfluous features and having a working base to code on. I have a ton of coding to do and I'm not asking the dev to do it for me since these are specific modifications only useful for my game. Don't tell me path-finding is specific when literally 50% of the TD games use it.

    Ps : As I said f I didn't saw the work that have been put into this I would've already written a bad review.
     
  34. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Anyway... The latest update is now live. I've make some tweaks to the path-finding and added new option for path-smoothing. I hope this settle the issue.
     
    Chaz32621 likes this.
  35. sala3000

    sala3000

    Joined:
    Jan 15, 2018
    Posts:
    8
    Thanks songtan, I am really grateful that you worked on this issue, but even after the update I'm still getting the same result :(. This is a map with only start-platform-finish and nothing else not even towers, it's still far from the shortest path, and I've activated path-smoothing of course. Is there something I'm missing?
     
  36. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Look for a gameObject AStar in the scene, try enable the option Diagonal Neighbour and set the Smoothing type to Free. Hover your cursor over those option for tooltip if you need more information.
     
  37. sala3000

    sala3000

    Joined:
    Jan 15, 2018
    Posts:
    8
    My bad, didn't apply the update correctly.
    This update is just wonderful, now that's some great pathfinding, thank you so much for your dedication and responsiveness songtan.
     
  38. primarygod

    primarygod

    Joined:
    Jan 16, 2017
    Posts:
    9
    hello again, I have a question. I am building my TD as huge platform city. Game map s very big. Everything works perfect no matter the sizes EXCEPT the ability. While in gameplay when I try to use Strike ability it seems that I have limited (kinda small) area of using this ability. Am I missing some configuration for the area of the ability? How can I expand it. Also the ability is limited to 0 height (Z) but my platforms are a little bit above. Any suggestions?
     
  39. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The detection of ability cast area is determined by the terrain object. That is any collider in the scene with the layer 'Terrain' (31). So as you build your level, adjust your terrain to match. Make sure it covers the field of view of the camera and match the height of your platform. In most case, you can just make sure the x and y value of the scale to some large value so you need not worry about the coverage of the fov. Hope this help.
     
  40. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Song, any clue the UI Flashing works fine in editor, but not ported out to a mobile device?
     
  41. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm not sure what exactly are you referring to. Can you elaborate?
     
  42. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    So, when I go to do a spell. The selected spell once selected flashes the ui. This is one of the buttons with Disabled, and Highlight. Well for some strange reason it works fine in the editor scene but once ported to a mobile build. That Highlight view of the button does not appear. It just still shows the button. You have the UI_Flashing script attached to them.

    It may not even help im using 2018 build of unity.... But I like being current....
     
  43. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I have just test it on my mobile and it's working. But then I'm running Unity5.5. Thing is the flashing is disabled by default. Did you enabled it?

    I'm not sure if it's due to the version of unity. As far as I can tell, it shouldn't make any difference.
     
  44. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    I finally got it to work, just deleted it and recreated the buttons. Must be a unity3d thing. Pretty wacky right now with this new beta build. But the features out weigh the issues lol. Stay tuned for more questions :)
     
  45. lpye

    lpye

    Joined:
    Aug 2, 2012
    Posts:
    30
    Hi songtan,

    I'm finding your toolkit very useful, thank you. :)

    Two issues I'm having:

    1) When I attempt to update from 4.0.1 f4 to 4.0.1 f5, it appears to remove all of my towers/creeps from the database. Is there a way to prevent that?

    2) I'm running into a problem where sometimes (but not always) my 'Turret' type creeps will stop moving. A little bit of debugging appears to suggest they are in fact being "moved" but the movement vector is zero length. Any thoughts?

    Thanks. :)
     
  46. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thanks.

    1) Just uncheck the 'Resources' folder when importing. All the settings are stored there.

    2) I'm not aware of this. Have you enable the StopToAttack option? After they stop moving, are they stuck there forever?
     
  47. lpye

    lpye

    Joined:
    Aug 2, 2012
    Posts:
    30
    Thanks, I managed to upgrade.

    As for the creep problem, yes they (4 types of units) are set to StopToAttack, and they stop out of firing range of the tower (i.e. any tower I place, when the problem arises, they halt outside of what appears to be their firing radius, but they don't fire and they don't move). If I sell the tower or if another creep spawns that for whatever reason does not suffer the same problem, then the once stuck creep continues on. If I were to drop another tower in range of the creep that was once stuck, it will stop and begin attacking again.

    I keep wondering if there is a link between the effective range of the creep-as-turret, the delay between attack animation loops, and the falloff range of the shoot object.

    Thanks.
     
  48. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I tried but I can't seem to replicate the problem you describe. Can you try with the default creep (the tank)? Does it have the same problem? If not, perhaps you can send me your offending prefab and so I can try it on my end.
     
  49. lpye

    lpye

    Joined:
    Aug 2, 2012
    Posts:
    30
    The default tank doesn't exhibit the problem. And when I reset the 'Effective Radius' of the creep to 2.5 (matching the tank) and the 'Fall Off Range' of the associated ShootObject to 3 (again, matching the tank) the problem disappeared. I *think* the values were equal before. On one of my tank creeps I bumped the values up by 1 each and got the expected results.

    TL;DR: I believe it was my error.

    Thanks for the assistance. :)
     
  50. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    That's interesting. I've tried playing with the value but have no success in replicating the error. As far as I know, increasing the value, or have it mis-match shouldn't break anything. Do let me know if you have the same problem again or find a reliable method to replicate it.