Search Unity

TowerDefense ToolKit 4

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

  1. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm not sure how to answer the question. There's probably quite a few solution available and the question is too broad to answer in one stroke. Plus I'm not familiar with AR, or know what are the specific functionality you are want to incorporate.

    If you are familiar with code, I suggest you look into FPSControl.cs. All the code concerning fps camera is there. From there, you should be able to figure out what to do.

    Or you can just somehow make sure both the camera share the exact same view port and same control input. But this will probably require you to play with the code as well.

    I'm sorry if what I'm saying is a bit vague.
     
  2. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    Hi Help how to make a gun in two different guns. rocket and machine gun at the same time. sorry for my English
     
  3. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid I don't understand your question at all. Are you referring to the FPS mode? Fyi, you can't have a weapon that fire two different shoot-object. You can only switch between 2 different weapons.
     
  4. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    not fps mode.
     
  5. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    the tower of the instruments missiles and a machine gun.

    2 on the tower guns missiles and a machine gun.
    EFFECTS different shooting ShootPoint.
    Now I hope you understand?
     
    Last edited: Feb 21, 2017
  6. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    So a single tower that fires two different shoot-object? I'm afraid that is not supported as well.
     
  7. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
  8. detomato

    detomato

    Joined:
    Aug 16, 2013
    Posts:
    54
    Unfortunately, I have not much idea with coding. Basically I would like to change my default cam to a FPS cam, without having to go through the tower. I am sure its possible.

    Thanks.
     
  9. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It's certainly possible. But you will need to work with the code. At the very least, you will need to disable the default camera control code and replace it with the FPS one. Also the FPS camera code in TDTK doesn't support movement, so you will probably need to add that too.
     
  10. riquid

    riquid

    Joined:
    Mar 18, 2015
    Posts:
    20
    I just purchased TDTK. TDTK is the only package installed. I am running Unity 5.5.0f3
    When running the demo levels I get frequent argument out of range errors. They seem to occur randomly when a creep is killed. The creep will freeze in place and towers will no longer fire at the creep but it will not disappear. It seems to occur both in the editor and in a built .exe
    Some examples of these errors are:
    Code (CSharp):
    1. ArgumentOutOfRangeException: Argument is out of range.
    2. Parameter name: index
    3. System.Collections.Generic.List`1[UnityEngine.Vector3].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    4. TDTK.UnitCreep.CalculateDistFromDestination () (at Assets/TDTK/Scripts/UnitCreep.cs:356)
    5. TDTK.UnitCreep.Init (TDTK.PathTD p, Int32 ID, Int32 wID, TDTK.UnitCreep parentUnit) (at Assets/TDTK/Scripts/UnitCreep.cs:109)
    6. TDTK.UnitCreep.Destroyed (Single delay) (at Assets/TDTK/Scripts/UnitCreep.cs:338)
    7. TDTK.Unit.ApplyEffect (TDTK.AttackInstance attInstance) (at Assets/TDTK/Scripts/Unit.cs:449)
    8. TDTK.ShootObject.Hit () (at Assets/TDTK/Scripts/ShootObject.cs:468)
    9. TDTK.ShootObject+<EffectRoutine>c__Iterator3.MoveNext () (at Assets/TDTK/Scripts/ShootObject.cs:272)
    10. UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
    11.  
    Code (CSharp):
    1. ArgumentOutOfRangeException: Argument is out of range.
    2. Parameter name: index
    3. System.Collections.Generic.List`1[UnityEngine.Vector3].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    4. TDTK.UnitCreep.FixedUpdate () (at Assets/TDTK/Scripts/UnitCreep.cs:183)
    Code (CSharp):
    1. ArgumentOutOfRangeException: Argument is out of range.
    2. Parameter name: index
    3. System.Collections.Generic.List`1[UnityEngine.Vector3].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    4. TDTK.UnitCreep.CalculateDistFromDestination () (at Assets/TDTK/Scripts/UnitCreep.cs:356)
    5. TDTK.UnitCreep.Init (TDTK.PathTD p, Int32 ID, Int32 wID, TDTK.UnitCreep parentUnit) (at Assets/TDTK/Scripts/UnitCreep.cs:109)
    6. TDTK.UnitCreep.Destroyed (Single delay) (at Assets/TDTK/Scripts/UnitCreep.cs:338)
    7. TDTK.Unit.ApplyEffect (TDTK.AttackInstance attInstance) (at Assets/TDTK/Scripts/Unit.cs:449)
    8. TDTK.ShootObject.Hit () (at Assets/TDTK/Scripts/ShootObject.cs:468)
    9. TDTK.ShootObject+<EffectRoutine>c__Iterator3.MoveNext () (at Assets/TDTK/Scripts/ShootObject.cs:272)
    10. UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
    11.  
    Code (CSharp):
    1. ArgumentOutOfRangeException: Argument is out of range.
    2. Parameter name: index
    3. System.Collections.Generic.List`1[UnityEngine.Vector3].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    4. TDTK.UnitCreep.FixedUpdate () (at Assets/TDTK/Scripts/UnitCreep.cs:183)
    5.  
    Any ideas about how this can be fixed?
     
    Last edited: Mar 2, 2017
  11. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Hi @riquid, Thanks for your purchase. I've done a quick test and run into the issue myself. To be honest I'm not sure what is the cause of the error and It could take some time to figure them out. Please bear with me while I try to fix the error. At the mean time can you send me an email? I'll email you the fix as soon as I've got them.
     
  12. riquid

    riquid

    Joined:
    Mar 18, 2015
    Posts:
    20
    I've been working with TDTK for a little bit now and am very impressed. I have a few quick questions for you.
    1. How would I go about spawning a wave where my own code determines the number and type of units in each subwave?
    2. Am I able to alter the endpoint of a path on the fly?
    3. If I am using OnCreepDestination event when a creep reaches it's destination, is there an easy way to determine which path that creep was on?
    4. What would be the best way to make the player unable to place a certain kind of building next to another certain kind or to require a player to place a building next to another kind of building?
     
    Last edited: Mar 9, 2017
  13. Song_Tan

    Song_Tan

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

    1. This is not easy and will require some amount of work. The SpawnManager by default will only spawn the predetermined wave from the spawn list. You will need to write your own function (or at least modify the existing one) to spawn an wave generated during runtime. And of course you will need to somehow keep tracked the spawned creep. You will find all the default responsible for all this in SpawnManager.cs. About the wave itself, you can find the class definition in TDTK_Class_Wave. That should give you an idea of what information constitute a wave.
    2. You should be able to. In fact, you should be able to modify the position of any waypoint on the path on the fly. It should be fine as long as it's not a platform.
    3. Each creep has a reference of the path it's traveling on. So it shouldn't be a problem. Look for line53 of UnitCreep.cs.
    4. You will need to do the check in BuildManager when the tower is about to be built, specifically in _CheckBuildPoint(). The function by default use a OverlapSphere() method to detect any obstacle in the way. You can probably use similar method to detect if there's anything been build in the adjacent tile, then check with the built tower if the tower in question can be built or not. But of course, first you have to somehow specify which tower is dependent on which tower and which tower will block which tower. This should be doable by adding a reference list of in the tower.
    Hope this help.
     
  14. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    Hi there

    Im getting this error message when testing

    NullReferenceException: Object reference not set to an instance of an object
    TDTK.ShootObject.FPSHit (TDTK.Unit hitUnit, Vector3 hitPoint) (at Assets/TDTK/Scripts/ShootObject.cs:213)
    TDTK.ShootObject.OnTriggerEnter (UnityEngine.Collider collider) (at Assets/TDTK/Scripts/ShootObject.cs:204)

    And this error message

    NullReferenceException: Object reference not set to an instance of an object
    TDTK.ShootObject.Hit () (at Assets/TDTK/Scripts/ShootObject.cs:446)
    TDTK.ShootObject+<MissileRoutine>c__Iterator7.MoveNext () (at Assets/TDTK/Scripts/ShootObject.cs:420)
    UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

    Can anyone please let me know why this is happening

    By the way this is one of the best assets i have used

    Many thanks
     
  15. Song_Tan

    Song_Tan

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

    The first error is a know bug. Try change line197 of ShootObject.cs to:
    Code (csharp):
    1. if(!hit && type!=_ShootObjectType.FPSProjectile) return;
    This should fix the error.

    However I'm not too sure about the second error. When are you experiencing it? In the demo scene using the default tower? Which one?
     
  16. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    when in spawnmanager check the box to auto generate is when you get this error
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. TDTK.Unit+<SupportRoutine>c__Iterator6.MoveNext () (at Assets/TDTK/Scripts/Unit.cs:567)
    3. UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
     
  17. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    thats already there
     
  18. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    Looks like it happens with CreepVehicle prefabs only
     
  19. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    My bad about the earlier post, It should have been -
    Code (csharp):
    1. if(!hit || type!=_ShootObjectType.FPSProjectile) return;


    As for the latest post, It's not about the auto-generate spawn. Just the creep itself, the support creep specifically. However I'm not entirely sure what is wrong. The prefab seems to be working fine on my end. You can try edit line567 of Unit.cs to following to get rid of the error.
    Code (csharp):
    1. if(unit!=null && !unit.IsDestroyed()) tgtList.Add(unit);
     
  20. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    Will test this out and let you know.

    Also one other thing is when in spawn manager when clicking the button to auto gen does nothing.
     
  21. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    These code changes worked just fine no more errors on that

    Many thanks for the quick replies
     
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Good to know. I'll check on the auto-generate button later.
     
  23. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    This is the error that comes up when clicking the button

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. TDTK.WaveGenerator.Generate (Int32 waveID) (at Assets/TDTK/Scripts/Class/TDTK_Class_WaveGenerator.cs:136)
    3. TDTK.SpawnEditorWindow.OnGUI () (at Assets/TDTK/Scripts/Editor/W_SpawnEditor.cs:97)
    4. 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/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
     
  24. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Alright, the error occur because you haven't assign any path to the path list in the configuration tab. Hence the generated wave haven't got any path assigned to them.

    Ultimately, you can get rid of the error message by changing line136 of TDTK_Class_WaveGenerator.cs to following:
    Code (csharp):
    1. float pathDist=wave.subWaveList[i].path==null ? 0 : wave.subWaveList[i].path.GetPathDistance();
    However it's still recommended that you have the path list assigned.
     
  25. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    Thank you that sorted the problem out
     
  26. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    I can say i love this toolkit full version

    I want to make a highscores table but i need to know where or how to access the cash value you have here.
    So that i can make my highscores and save the scores

    any help would be great many thanks
     
  27. Artlekks

    Artlekks

    Joined:
    Mar 5, 2015
    Posts:
    3
    Hi Song,
    Thank you for this asset, really great !
    I have ran into some troubles and if you have time, could you help me ?
    Here are 2 screenshots showing what's wrong.
    In short, when I click on the first Grid and last Grid on the path, I can only select the "TowerMine" which is fine but it is all over the place...
    I would like to place it above the selected grid as it should be I believe and behave like when it is on the pie menu if I select any other grid.
     

    Attached Files:

    Last edited: Mar 28, 2017
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Sorry for the late respond. I've missed the new post notification again.

    @micheal332001, what are the value you are looking for exactly? You mean the resource value from ResourceManager? Try:
    Code (csharp):
    1. List<Rsc> rscList=ResourceManager.GetResourceList();
    2. for(int i=0; i<rscList.Count; i++) Debug.Log(rscList[i].value);

    @Artlekks, It's a bug I'm afraid. I believe I've fixed it in the latest update which has just gone live a few hours ago.
     
  29. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    thank you worked it out in the end.

    Just tried the your new version just released and have not changed or added anything just had a look at your scenes you made, and when you open the perks it shows no perks and also it will not let you close it.
     

    Attached Files:

  30. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
  31. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    yes you are right was trying it with 5.6 will change this and see what happens.
     
  32. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    same problem even in unity 5.5 since the upgrade to your new version even some of the buttons dont work now
     
  33. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    have changed the scroll type and the buttons and that are working now but still dont show the perks in the list
    upload_2017-4-14_8-15-2.png
     
  34. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Which scene you are using exactly? Did you create one from the drop down menu or copy one of the demo scene? It works fine for me after I change the movement type to elastic. Make sure you do the change before you run the scene. You can check on the ContentRect object under Mask. There shouldn't be any NaN value on the RactTransform.
     
  35. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    RactTransform
    left 1.589316e+08
    right -1.589316e+08
    y 5
    z 0
    height 100

    these are the values i have there
     
  36. micheal332001

    micheal332001

    Joined:
    Mar 18, 2017
    Posts:
    27
    just changed these to 1.5 and its working now
     
  37. alexsander890

    alexsander890

    Joined:
    Apr 15, 2013
    Posts:
    61
    Hi
    What's new in version 3.1.1 f5?
     
  38. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Not much really. There are some minor bug fix from the various feedback I gathered but it's mostly for some UI tweaks to get it working with Unity5.6.
     
  39. g0tNoodles

    g0tNoodles

    Joined:
    Nov 28, 2010
    Posts:
    193
    Hi Song,

    I have been away from making my game for some time, in fact, the version of TDTK is from March 2016...I have come across the issue where the slow effect is not being applied when also applying damage. I am not wanting to update the package for now as it does everything I need...how was this fixed?

    Thanks.
     
  40. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid I no longer keep a copy of the earlier version and I can't quite remember how that bug is fixed. The best thing you can do now is to send me your copy of the code. I'll get it fixed and send it back to you.
     
  41. ConfusedHamster

    ConfusedHamster

    Joined:
    Apr 19, 2017
    Posts:
    3
    I was working on my own TD project earlier, till I got a confused with the wave management. TDTK is well worth the money! Thank you Song for releasing!

    Not trying to bog you down with requests, but and I had a free drag and drop system similar to Bloons TD. Where you could drag your tower onto to the level, as long as the tower didn't collide with another turret, the enemy road, or an inaccessible area, the unit could be dropped. I see in TDTK you need a platform object to place anything.. I'm still learning how it works, do you think you could explain how I could work this out? My path is curved and 3D and stuff, so a grid just can' work for me :(

    And I noticed you said you're working on a TDTK4 :), do you think we will see free drag and drop or spline/curvy paths in the next version?

    Thank you sir!!
    ConfusedHamster.
     
  42. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Hi Hamster, Glad you like the framework.

    You can checkout the function CheckBuildPoint() in BuildManager.cs. That is where the tower placement logic is located. Basically it tries to get a platform, snap to the nearest build point and proceed to check if that build point is available or not. What you can do is modify this function so that it can be placed as long as it doesn't collider with other object. Obviously you will have to setup your own system to determine any possible collision. Technically it should be pretty straight-forward. Since you dont need positional snapping or check platform viability, it can be as simple a simple Physic.SphereCast to see if it's intersecting with any collider.

    I'm in fact working on TDTK4. However I'm not sure yet if I'll add support for free-form tower-placement. To be honest, I'm trying to reduce the dependencies on physics and collider. Therefore the new system is as far away from the collision based system as it can be. I'll give it some thought anyway. We'll see.
     
  43. ConfusedHamster

    ConfusedHamster

    Joined:
    Apr 19, 2017
    Posts:
    3
    Thanks for the reply Song!

    But I've been trying to make it work for a few hours now (...:confused:), and I still can't get it right. When you have some free time do you think you could please post a snippet showing how this can be done?

    ConfusedHamster
     
  44. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Alright, instead of the default code, the CheckBuildPoint() you need could look like this:
    Code (csharp):
    1.  
    2. public BuildInfo _CheckBuildPoint(Vector3 pointer){
    3.    BuildInfo buildInfo=new BuildInfo();
    4.    buildInfo.status=_TileStatus.Blocked;
    5.    
    6.    Camera mainCam=Camera.main;
    7.    if(mainCam!=null){
    8.        Ray ray = mainCam.ScreenPointToRay(pointer);
    9.        RaycastHit hit;
    10.        LayerMask mask=1<<TDTK.GetLayerTerrain();
    11.        
    12.        //Perform a raycast against the terrain to pick up a point
    13.        if(Physics.Raycast(ray, out hit, Mathf.Infinity, mask)){
    14.            buildInfo.position=hit.point;
    15.            
    16.            //do a spherecast against everything but the terrain to see if the point is occupied by other object(collider)
    17.            Collider[] cols=Physics.OverlapSphere(hit.point, towerSize, ~mask);
    18.            if(cols.Length==0) buildInfo.status=_TileStatus.Available;   //if no collider, set the build status to available
    19.        }
    20.    }
    21.    
    22.    return buildInfo;
    23. }
    24.  
    The problem now is by default buildInfo will need to have a platform assign to it. When a new tower is build, it will register itself onto the platform. You will find that in DragNDropRoutine() in UnitTower.cs (and maybe somewhere else, I can't remember them all). What you need to do is remove the code that involve access the platform on the buildInfo instance.
     
  45. ConfusedHamster

    ConfusedHamster

    Joined:
    Apr 19, 2017
    Posts:
    3
    Just a little update, I achieved free drag and drop by removing BuildManager and a GUI object from the scene, and replaced with my own. :)
     
  46. ctidavis

    ctidavis

    Joined:
    May 18, 2017
    Posts:
    3
    Perhaps I'm missing something simple, but I can't figure out how to allow the user to select target priority for towers like they could in the free version (strongest, weakest, first, last, etc). I saw that there is some code for this, but is there an easy way to add this back into my project?
     
  47. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm out of office this week so I can't check for sure but if I remember correctly there should be a option on UIObject (the UIControl component) that turn target priority on or off. When turned on, the option will show up when a tower is selected.
     
  48. ctidavis

    ctidavis

    Joined:
    May 18, 2017
    Posts:
    3
    No problem. I'm not in too much of a hurry.
    I can't seem to find it on the UIObject. Perhaps the option is on something else?
     

    Attached Files:

  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I finally have a chance to check. While the code for targeting priority is there and working, for some reason there's no option in the default UI for the player to change it during runtime. You will have to add it yourself. The only function you need to call is IterateTargetPriority() on the tower instance. That will cycle through all the available target priority.
     
  50. imgumby

    imgumby

    Joined:
    Nov 26, 2015
    Posts:
    122
    Hi
    What's this now with TDTK 4.x showing up in asset store separate from TDTK 3.x...I would have hoped existing customers would get free updates as usual....is TDTK 3 going to be deprecated leaving us with an empty bag and having to shell out another $60 to keep current ($120 total) when a new user gets the current version for $60?? ???