Search Unity

  1. 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. hungseparate

    hungseparate

    Joined:
    Aug 25, 2014
    Posts:
    10
    Hi, i got some problems with ios platform. By default, my platform is "PC", mode drag work fine with it, but after i change to ios platform to layout my own UI, i cant drag anymore ???
    is it a bug or i need to build on real device to run dragndrop ?
     
  2. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    It's not a bug. The game stop responding to mouse input and switch to touch input when you set the target platform to iOS (or any other mobile platform for that matter). You will have to run it on a touch device. If you are unaware, check out UnityRemote. It is very useful to test the touch input while running the game in Editor.
     
    hungseparate likes this.
  3. hungseparate

    hungseparate

    Joined:
    Aug 25, 2014
    Posts:
    10
    one more thing, i want to use NGUI in my game, but in your unit object, editor.... is using unity Sprite.
    I tried to change it to UISprite of NGUI, but it alot complicate.
    So there is any other way to do this ?

    p/s : i saw a bug in "gun info dialog". when i click or hover , it keep disable, enable then repeat (a lot) and i cant touch to build gun.
     
  4. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    For NGUI, I would recommend you to use string to store the sprite name. Something like this:
    Code (csharp):
    1. public string iconName="TowerIcon";   //the name of the tower icon
    2. public UISprite spriteObject;   //the ui sprite object
    3.  
    4. spriteObject.spriteName=iconName;   //get the sprite object to show the tower icon
    Thanks for the feedback on the bug. I'll look into it.
     
  5. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    Hi all, just a quick note that I'll be away for the next few days. Apologies in advance for any inconvenience. I'll try to respond to any post/email/question as soon as I can.
     
  6. hungseparate

    hungseparate

    Joined:
    Aug 25, 2014
    Posts:
    10
    I want to ask about machine tower when it shoot at target.
    I got my machine gun tower cooldown at 0.1, that mean it will continuous shooting at creep.
    But i notice that when creep go near tower, tower need to rotate to aim at creep, at this moment it stop shooting about 0.5s.
    if i set barrel object and aim rotate it will continuous shooting but i dont want my barrel to rotate.
    any suggest to fix this problem ?

    p/s ; you can check my video here
     
    Last edited: Oct 29, 2015
  7. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    I guess the problem is the turret isn't rotate fast enough to keep the creep in aim. The tower won't fire if the target is not line up with the the shooting direction. What you can do is increase the turret rotate speed. The value is specified by variable "turretRotateSpeed" in Unit.cs, approximately at line235.
     
    hungseparate likes this.
  8. hungseparate

    hungseparate

    Joined:
    Aug 25, 2014
    Posts:
    10
    I change it to 20 and it work like a charm ;)

    And about tower range, i just saw that tower begin shooting at creep before it enter the red circle ?
     
    Last edited: Oct 29, 2015
  9. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    There could be a few reason behind this. Either the collider on the creep is too big, or the texture on the range indicator (the circle) is not stretched to the end, or the scale value used int eh script is off due to the mesh you are using for the indicator. If you are using the default prefab, the first one being the most likely causes. Try to make the collider on the creep match the size of the mesh (or smaller).
     
  10. hungseparate

    hungseparate

    Joined:
    Aug 25, 2014
    Posts:
    10
    Just find out that scale of my tower is a problems. Basiclly the red circle is scale, but some how it collider not. I'll find another way to fix. Thanks for your support.
     
  11. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    190
    Hi Songtan. I would like to know how to set platforms for specific towers, even ones that are locked. I have "disable in build manager" checked for some towers that can be unlocked via PerkManager. Once I unlock a new tower I don't want it to be available to build on all platforms, rather only specific ones.
     
  12. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    Hm... That's a good point. I never thought of that myself. Please give me some time to look into it, I'll get back to you later.
     
  13. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    190
    I hacked it for now by adding an check in BuildManager.AddNewTower.

    My new problem is loading/saving Perks using PlayerPrefs between play sessions. Any suggestions?
     
  14. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    Well, there's actually a pretty easy fix to the issue with the tower availability on platform. Just remove line77 (if(tower.disableInBuildManager) continue;) in PlatformTDEditor.cs. Then you should be able to enable/disable the tower that is not available immediately.

    Regarding loading and saving perk, you can easily use PlayerPrefs to save the ID of each purchased/unlocked perk. Then what you need to do is load the saved ID to replace purchasedIDList in PerkManager at the start of each game (I left a comment at PerkManager.cs, Init() to show specifically where the saved purchasedIDList needs to be loaded) . The script will do the rest.

    By the way I just notice that the saving can be made a lot more easier if you can just save the purchasedIDList. I'll need to modify the script a bit for that. Please send me an email so I can send you the modification as soon as I'm done.
     
  15. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    190
    Thanks for the quick responses. I'll try that out.
     
  16. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    Well, thanks to you. I've done a quick revision to the existing code and implemented a save/load system for the perks. I'll be very happy to send you the modified code instead of waiting until I update the package (which I plan to do in the next few days).
     
  17. AndyMul

    AndyMul

    Joined:
    Jul 13, 2013
    Posts:
    41
    Woohoo... save/load system for the perks. Been waiting for this one.

    I just saw the updated version in the asset store.

    Do you have the list of new features, songtan?
     
  18. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    Well, the release note contains pretty much all the changes worth mentioning. :)

    So this is the official statement, version 3.0.1 f3 is now out and live on AssetStore. The release note is as follow:

    - saving & loading for perk system has been added
    - built and destroyed effect is now shown in tower editor
    - fixed an editor error where some tower not show up on Platform editor
    - other minor bugs fix​

    note: the update applies to Unity5.0 and above only
     
  19. drelbon

    drelbon

    Joined:
    Sep 14, 2015
    Posts:
    1

    HI! how did you get your build animation to work ? i tried something similar, but my animations keeps playing where i made it. I moved the animations, scripts, animator to different Objects in the hierarchy, created dummy objects to hold the scripts animations etc. but everything ive tried gives the same result...the build animtion plays where it was made NOT where the tower is being built !

    any help on this would be most appreciated.
     
  20. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    Fyi, the position of the script matters not. This has to do with how how your animation clip is created, specifically, the animated object's (the object with animator component) position when the clip is played. Make sure it's (0, 0, 0), then you can move the animated object into a dummy transform where it will always centered at the dummy transform. Then you can move the dummy transform anywhere without having the animated object position locked to the world space.. This is the reason why all the meshes in the default tower is placed as child object, not the root object. So when they are animated, their position is still locked on to the root object.

    Make sense?
     
  21. B1Gone

    B1Gone

    Joined:
    Nov 25, 2015
    Posts:
    1
    hi song,
    how can i change the phathindicator to run only once (per wave).
    Thanks in advance
     
  22. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    Well, you will have to modified the script PathIndicator.cs. First by having the indicator stop looping and emitting after completing a run. Then you can listen to SpawnManager.onNewWaveE (which fired whenever a new wave start) and start the run function again each time the event is fired.

    It's pretty easy tbh. I can do it if you can wait a bit. Please send me an email so I can mail you the modified script when I'm done.
     
  23. KennethOAguilar

    KennethOAguilar

    Joined:
    Feb 25, 2015
    Posts:
    6
    Is it possible to change from grid placement to free placement?
     
  24. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    It's possible however it's not supported by default. You will have to do some customization of your own. Depends on your game, it could be relatively simple.
     
  25. KennethOAguilar

    KennethOAguilar

    Joined:
    Feb 25, 2015
    Posts:
    6
    how would i b able to achieve this? any helpful ideas?
     
  26. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    The key is in BuildManager.cs. The function _CheckBuildPoint() is called whenever the user try to initiate a build menu or drag a tower to a point in drag-n-drop mode. The function round the build position to the nearest build point on a platform and store all the information of the build attempt in buildInfo. What you can do is modify the default _CheckBuildPoint() to ignore the all the checking regrading the build platform and just do a simple obstacle check so that the towers don't get built on top of each other. So ultimately it depends on the footprint of the tower and how you are going to check if the tower is overlapping. Note that you still need to store the information on buildInfo for the rest of the code to work.

    Hope this helps.
     
  27. KennethOAguilar

    KennethOAguilar

    Joined:
    Feb 25, 2015
    Posts:
    6
    Perfect, thank you very much!
     
  28. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    190
    Hey Songtan. I see a difference in movement speed of creeps when I play my game on iPhone compared to PC. In MoveToPoint you use both Time.deltaTime and Time.fixedDeltaTime. I think it should only be Time.deltaTime since the method is called from Update.
     
  29. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    You are right. Good spot. Thanks for letting me know.

    Actually the MoveToPoint() is called from FixedUpdate() so it should have use Time.fixedDeltaTime.
     
  30. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    190
    Hmmm...then I must of moved it for some reason. Thanks :)
     
  31. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    108
    I don't recall exactly how I went about creating this, but I know that it's based on this:

    Song, I'm seeing that the Build Duration adjusts how long it takes to build a tower, but the tower appears during that duration. Would it be difficult to add tick box that gives you the option for a tower to appear right away or only appear when the delay has finished? I too am not that great with animations yet, so I think this could be very helpful in getting an animated Building Effect working easier. For my situation, all I would need to do is tick the box to hide the tower until the duration has timed out, then the tower will appear in place of the dummy turret that I raised up from the ground and then destroyed at same time as duration timeout. Thanks :)

    Here are a few pics showing the silo (that already had animation)
    https://mknkt54321-gmail.tinytake.com/sf/NDIwMDEzXzIyOTk4MTY
    https://mknkt54321-gmail.tinytake.com/sf/NDE5OTk4XzIyOTk3NzA
    https://mknkt54321-gmail.tinytake.com/sf/NDE5OTY5XzIyOTk3MTA
    https://mknkt54321-gmail.tinytake.com/sf/NDE5OTk5XzIyOTk3NzE
    https://mknkt54321-gmail.tinytake.com/sf/NDE5OTczXzIyOTk3MTQ
    https://mknkt54321-gmail.tinytake.com/sf/NDE5OTg5XzIyOTk3NDA
    Here's the video showing the animation in action. https://goo.gl/O62Pwe

    I dragged the prefab into a scene in the hierarchy, and placed the wood crate as a child of the platform. Then placed the PL"silo" under an empty prefab called Silo. I was also using a Fade script & DestroyAfterTime. Hopefully this helps, good luck :)
     
    Last edited: Dec 15, 2015
  32. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    This is exactly what the checkbox "HideWhenBuilding" is for. When checked, the visible mesh of the tower will be hidden during the building process. It will then appear when the building is done.
     
  33. apie2546

    apie2546

    Joined:
    Sep 13, 2015
    Posts:
    14
    this may have already been answered, however, I switched the platform to Android and I got multiple errors yesterday about enabletouchpan? For the life of me I can't find the file, but I basically commented out that part causing the issue and I fixed it, bug? Also when I am using the demo scene on a Android phone, the tower info glitches, is there a way to change the pop up of tower info from on hover to on touch? I've scoured the code and only got to event system onhoverstatus
     
  34. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    Can you give show me the error message you are having? I've just tried on my end and I don't encounter any error.

    The tower info however does glitch out when using PointNClick build mode. A simple fix to that would be adding line if(UIUtilities.IsCursorOnUI()) return; at the first line of OnTouchCursorDown() (line130) in UI.cs. Alternatively you can use DragNDrop mode, which doesn't have the same issue.

    There's no way to change the tower info pop up from on hover to on touch atm I'm afraid. Not unless you change the code to a 2 tap system where you tap on the button once to bring up the tower info and another tap to build the tower. However I'm currently working on a big update to overhaul the UI. I'll try to add that if I can.
     
  35. mahdijj

    mahdijj

    Joined:
    Sep 24, 2015
    Posts:
    31
    hi
    when i use from terrain in game ,creeps remain in first and dont move.how i can solve this problem?
     
  36. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    Are you using mazing (walkable platform) in your scene? My guess is that the collider on the terrain is enabled and it blocks out all the possible path. With no possible path to gets to destination, your creeps end up stuck. You have to either disable the collider or change the layer on the terrain object to the terrain layer (26 by default).
     
  37. mahdijj

    mahdijj

    Joined:
    Sep 24, 2015
    Posts:
    31
    thanks for useful support
    when publish update for tdtk?
     
  38. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    I cant tell for sure. But hopefully it will be ready within a week or two.
     
  39. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    190
  40. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    It's me who should be thanking you for using TDTK.

    A reverse tower defense? Interesting... I'll check it out when I have time.

    Congratulation by the way!
     
  41. mahdijj

    mahdijj

    Joined:
    Sep 24, 2015
    Posts:
    31
    hi
    excuse me for this question
    when you publish update for tdtk and what is new features in new update?
    i want create a game and i am waiting to your update
     
  42. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    The new update should be ready pretty soon. Hopefully over the next few days.

    There wont be any new feature in term of game play. However there will be some big changes. For a start, there will be a new UI. Most of the editors has been rewritten. And finally a lot of changes has been made to the base code.

    Hope that answer your question.
     
  43. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    108
  44. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    Well, don't put too much hope into it. Visually it doesn't look very different. Most of the work is being put into the code and setup. It will make life a lot more easier if you want to modify/expand it. But for the most part, it will looks the same.
     
  45. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    108
    Simplicity is excellent, I still look forward to it :)
     
  46. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    Finally, the new update (v3.1) is out!
    • Major restructuring of most of the framework
    • New and improved UI (based on uGUI)
    • New Editors with improve usability (more intuitive, undo/redo support, multi-instance editing, etc.)
    • Tons of clean up and optimization
    Since there's a lot of big change, there may be some bug. So please let me know if you come across any.

    Important: Please note that the new version may not be entirely backward compatible, so make backup before you proceed to update it into your existing project.
     
  47. Binary42

    Binary42

    Joined:
    Aug 15, 2013
    Posts:
    168
    Hey,

    im trying to visualize creeps (aoe) buffing creeps, but i get the error below when i try to drag an Effect Shoot Object in to the Stats Effect Object of a support creep.

    InvalidCastException: Cannot cast from source type to destination type.
    TDTK.TDUnitEditorWindow.DrawShootEffectObject (Single startX, Single startY, TDTK.UnitStat stat, TDTK.Unit unit, Boolean isTower) (at Assets/TDTK/Scripts/Editor/W_UnitEditor.cs:571)
    TDTK.TDUnitEditorWindow.DrawUnitStatsSupport (Single startX, Single startY, TDTK.UnitStat stat, TDTK.Unit unit, Boolean isTower) (at Assets/TDTK/Scripts/Editor/W_UnitEditor.cs:422)
    TDTK.UnitCreepEditorWindow.DrawUnitConfigurator (Single startX, Single startY, TDTK.UnitCreep unit) (at Assets/TDTK/Scripts/Editor/W_UnitCreepEditor.cs:152)
    TDTK.UnitCreepEditorWindow.OnGUI () (at Assets/TDTK/Scripts/Editor/W_UnitCreepEditor.cs:99)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    Any helpful ideas? ^^
     
  48. annamo

    annamo

    Joined:
    Jan 4, 2016
    Posts:
    1
    Is there a soldier generator tower feature? ie. is there any way to have good guy boots on the ground?
     
  49. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,638
    @Binary42, I'm afraid that is a bug. You can fixed by changing line571 of W_UnitEditor.cs to following instead of waiting for a fix.
    Code (csharp):
    1. stat.effectObject=(GameObject)EditorGUI.ObjectField(new Rect(startX+spaceX-50, startY, 3*widthS+15, height), stat.effectObject, typeof(GameObject), false);

    @annamo, I'm afraid not. Not with the current version anyway. I'll try and see if I can add that in the future but don't put your hopes up
     
  50. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    393
    Hi

    Just wanted to report a bunch of errors when playing some of the scenes in Unity 5.3.1 as per screenshot...

    cheers

    Nalin
    TDTK Problems 5.3.1.png
     
unityunity