Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

TowerDefense ToolKit 4

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

  1. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    The problem occurred when I open them for the first after the update and I still have the same problem till now....

    (Later on the same day)
    it works fine when i imported to a fresh project but i have to readjust my spawnmanager because once i drag my folder to the new project the assigned creeps to the spwanmanager it disappear so i have to reassign them... thats y i hate importing to a new start....
     
    Last edited: Feb 8, 2013
  2. liverolA

    liverolA

    Joined:
    Feb 10, 2009
    Posts:
    347
    just update to the 2.2b,
    sometimes i got this error, in the terrain demo

    NullReferenceException: Object reference not set to an instance of an object
    BuildManager.CheckBuildPoint (Vector3 pointer, Int32 footprint) (at Assets/TDTK/Scripts/C#/BuildManager.cs:565)

    why?
     

    Attached Files:

    Last edited: Feb 8, 2013
  3. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    @Tsurugi, you should almost never directly drag one folder or any file from one project to the other. That's why you lost all your information on it. You should always export it via unity package and reimport it at another project. As for the error, I might have to look at your project to find out exactly what is wrong. So would you mind if I have a look. Perhaps you can send me a download link or something.

    @liverolA, it definitely not a game breaking error. I noticed the error too and am trying to find out why.
     
  4. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    its ok songtan i took the hard way though.... i just spend some time and re entering some number but thanks for tell me export import part....
     
  5. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    New Overview/QuickStart/Guide videos, please excuse the poor audio quality :)

    Full youtube playlist goes here

    TowerDefenseToolKit (TDTK) Quick Start - Part 1 Overview


    TowerDefenseToolKit (TDTK) Quick Start - Part 2 Editors


    TowerDefenseToolKit (TDTK) Quick Start - Part 3 Advance Scene Setup


    TowerDefenseToolKit (TDTK) Quick Start - Part 4 Creep


    TowerDefenseToolKit (TDTK) Quick Start - Part 5 Towers


    TowerDefenseToolKit (TDTK) Quick Start - Part 6 Perk System
     
    Last edited: Feb 9, 2013
  6. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    hey songtan... for the past few days i have been trying something creative... i try to merge some of the code from UI to UInGUI so that i can have the pie but after all the trail and errors i still cant perfectly do it..... plz help
     
  7. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    Sorry for the slow respond. I have been out of office and rather busy due to personal reason. it might take a few days before I can resume work full time. You can either wait for me to try add that to existing code, or let me know where are you getting stuck so I can figure out how best to proceed.
     
  8. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    i think i can wait for you... just wondering how long will you take to get back to your place?
     
  9. liverolA

    liverolA

    Joined:
    Feb 10, 2009
    Posts:
    347
    still many bugs in this version,but most of them you can fix yourself!

    1.check buildpoint bugs
    2.poolmanager spawn error
    3.sometimes the creep don't play dead animation,still move after dead
    ....(can't find in the examples,but if you have your own animated creeps you will find this error)

    a lot i can't remember them all,but these are not crucial so i fixed them myself
     
    Last edited: Feb 12, 2013
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    Noted, can you please let me know if you come across any more bugs. I'll fix them asap.

    I'll be probably back in office in a few days, probably next week.
     
  11. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    how do i import my own icons... what file type should i save it as?
     
  12. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    You can pretty much use any format (png, jpg, psd...) you want as long as it's supported by unity. Just drag the file into your project tab. If you are using NGUI, you need to add the icon to the atlas. As for how to do that, I suggest you watch the NGUI tutorial video on the NGUI website.
     
  13. dong dong

    dong dong

    Joined:
    Jan 12, 2013
    Posts:
    4
    i think you can tell him which fold or information can be revised,which fold can not be revised .
     
  14. webgovernor

    webgovernor

    Joined:
    Feb 10, 2013
    Posts:
    18
    Hi Song,

    When I start a new TDTK 2 project (imported the latest assets from the asset store), I've noticed that I'm unable to pick any "Transform" objects for EditorGUI.ObjectField (typeof(Transform)).

    I'm unable to select anything in the Tower Editor, for example. The TurretObj: has data in it, but if I select the little circle to choose a Transform, the list is blank.

    As always, any help is greatly appreciated. I've been stuck on this for several hours now, hoping to find my own fix. :(

    Thanks for all your hard work!

    Edit: I'm able to select a different transform when I place the prefab in the scene and then save it, but I have yet to find a way to remove the old turret when upgrading... would be nice to select in the TowerEditor though.

    Edit2: I've been able to work around this by adding my tower to the scene, duplicating the turret object and picking my models, moving the "upgrade" models waaaay out of the way (Z=-9000), and assigning them as the TurretObj: for the upgrade section. This works... but it's a little cumbersome. It could be that I'm missing something obvious.
     
    Last edited: Feb 16, 2013
  15. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    for some reason the override hp doesnt work in the spwanmanager....but override speed works..
    is there a option that i forgot to select to enable it?
     
    Last edited: Feb 16, 2013
  16. xgeraldx

    xgeraldx

    Joined:
    Oct 31, 2012
    Posts:
    10
    Is there anything special I need to do in order to utilize the new Mecanim system in unity 4 for my creeps?
     
  17. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    I'm extremely sorry with the slow respond. I have been having issue with my internet for the past few days.

    @webgovernor, For your information, all turretObject assigned to a tower has to be a prefab. I guess you have found that out. The old turret should be disable automatically by default as long as you have assigned it as a turretObject of previous level. Make sure the transform assigned is the root transform of the turret, other wise some part of it might be left active. You can refer to the example canon tower and see how it's setup.

    @Tsurugi, Thanks for pointing that out. I've check and it's definitely a bug. Please add this line 'HPAttribute.fullHPDefault=hp;' to SetFullHP() in UnitCreep.cs at line460. Alos, I've been working on the pie menu for NGUI. I'll send you an advance copy when it's done.

    @xgeraldx, Unfortunately the toolkit doesn't support the new Mecanim system yet. Sorry for that.
     
  18. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    Thanks for doing the pie chart for Ngui.... really appreciated if you are going to send it in advance...
    Also I found out that the healing creep doesn't heal air units
     
    Last edited: Feb 20, 2013
  19. zhing

    zhing

    Joined:
    Jul 6, 2012
    Posts:
    19
    $aim_system.png

    @songtan, I have made a small change to your Tower Aim System.
    Add a member "public Transform targetT;" to the Unit class.
    Add a method to the Unit class.
    PHP:
    public Transform GetTargetT() {
      return 
    targetT != null targetT thisT;
    }
    Then replace all "target.position" and "target.rotation" to "target.GetTargetT().position" and "target.GetTargetT().rotation" in the UnitTower.CS.
    I think this aim system will give the developers more custom features.;)

    BTW, SetFullHP() is in the Unit.CS Line 460, not UnitCreep.cs;)
     
  20. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    @Tsurugi, sent both the Pie Menu update and bug fix to your email.

    @zhing, I see what you did there and you are right and right! Thanks a bunch for the suggestion!
     
  21. Roobik

    Roobik

    Joined:
    Feb 21, 2013
    Posts:
    2
    Just purchased the paid version of TDTK and using with 4.0.1f2. I am trying to use the UI Unity game object (as opposed to UI NGUI), but I get this error after playing the scene and hitting the spawn button:

    Coroutine couldn't be started because the the game object 'UI' is inactive!
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    UI:DisplayMessage(String) (at Assets/TDTK/Scripts/C#/UI.cs:1381)
    UI:OnNewWave(Int32) (at Assets/TDTK/Scripts/C#/UI.cs:146)
    SpawnManager:SpawnWave() (at Assets/TDTK/Scripts/C#/SpawnManager.cs:246)
    <ContinousTimedSpawn>c__Iterator1B:MoveNext() (at Assets/TDTK/Scripts/C#/SpawnManager.cs:203)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    SpawnManager:_Spawn() (at Assets/TDTK/Scripts/C#/SpawnManager.cs:101)
    SpawnManager:Spawn() (at Assets/TDTK/Scripts/C#/SpawnManager.cs:333)
    UI:OnGUI() (at Assets/TDTK/Scripts/C#/UI.cs:531)

    This can be reproduced by opening the sample ExampleLinearMultiPath scene, activating UI, deactivating UI NGUI, playing the scene, and hitting the spawn button.
     
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    I tried follow your instruction but didnt manage to replicate the error. If you have indeed activated the UI gameObject and enabled the UI component, it sounds like you are having another UI component in the scene which is attached to an inactive gameObject. Please try to make sure there's only one UI component in the scene.
     
  23. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    for the next update can u add in where the editor can override the shield in the spawn editor like the function override hp and fast.....
     
  24. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    I'll see what I can do.
     
  25. cstever

    cstever

    Joined:
    Jan 6, 2013
    Posts:
    3
    is UIiOS still available or is it gone? I can't seem to find it. I'm new to unity but I've read the the OnGui stuff is evil; is the UINGUI what I am suppose to use for ios?
     
  26. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    I have stop support for UIiOS following Unity4. Yes OnGUI use to be 'evil' before Unity4 but it has been vastly improved as stated by Unity. I have managed to record higher framerate on device with OnGUI than NGUI when doing some quick testing. So it's perfectly fine to use OnGUI for iOS now. :)
     
  27. cstever

    cstever

    Joined:
    Jan 6, 2013
    Posts:
    3
    Great thanks.
     
  28. Mike_011972

    Mike_011972

    Joined:
    Jun 8, 2009
    Posts:
    97
    Hi Songtan,
    Bought your kit just over a month ago, but not had a real chance to us it in anger yet (finishing off current project (GoGo Digger)), but it looks really good so far.
    For my next project I plan on doing a TD game with your kit, but I’m unsure if I will be able to do a standard 2D TD game (with out any additional coding) where you use different sprites depending on the direction of movement (so up / down would be different set of sprites and animations (up you see the persons back, down you see the chest)). It needs to be 2D as I'm hoping to have lots of creeps on screen at once.
    If not, I’ll have to change my initial design ideas to work around it which wouldn’t be a bit deal, but would be a great feature at some point =)
    Either way, it’s still a really great kit and I can see myself spending lots of time playing with it soon.

    Thanks,
    Mike.
     
  29. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    hey songtan i was just wandering if fastgui for ngui is compatible or friendly with your tdtk....
    also is the next wave info gui fully customize-able?
     
  30. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    @mike, Thanks for your puchase but I'm sorry to say it's very likely that you wont be able to do a sprite based game using TDTK. You can try but it would be very restrictive and there's no guarantee that things would work as good as they are in 3D. The framework is intended for 3D asset. You can still have a lots of creeps on screen at once, even when using 3D model, if you optimize your asset well.

    @Tsurugi, I'm not sure about fastgui as I'm not familiar with it. But if it's ok with NGUI it should be compatible. I'm not sure what do you mean by 'fully' customise-able but if you are using NGUI you can change the position, font, font size and etc...
     
  31. Mike_011972

    Mike_011972

    Joined:
    Jun 8, 2009
    Posts:
    97
    Thanks Songtan for the quick reply.
    Not a problem, I'll change the visual style so it will work in 3D.
    If you ever make a 2D TDK, let me know and I'll buy =)

    Thanks again,
    Mike.
     
  32. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    thx... i just tried moving the wave info gui but every time i play the game it will go back to its original place...

    if its not to much can u make a video now your set up on ngui or show how to customize it... because after watching the tower and creep video i understand more about your tdtk...
     
    Last edited: Feb 27, 2013
  33. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    191
    When are you planning on releasing the next update? The last one has some issues with the new stuff you added.
     
  34. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    @Tsurugi,

    That's an error on my end. I've just checked again and yes you cant change the position yet. I'll get that fixed. I'm not too sure about a video about NGUI. It's a fine line to tread, I could easily end up with a very long video explaining how NGUI works in general. I'll think about it but please dont hold your breath. To compensate I'll briefly explain it here. Basically most of the gameObject assignment to the script are the gameObject contains element of NGUI such as UIButton or UILabel. Upon a certain function call by the buttons, or event call by the game, the property of those UI element will be altered. Say a new wave is spawned, the event will prompt the script to update the label on wave information. A tower is selected, the even will prompt the script to update all the UI element in the tower info panel, as well as activates it so it's visible. So on and so fourth.


    @DreamEnder. I'm actively working on the next update though I'm not sure when it will be ready. I do have a bit of contract work so regrettably I cant work full time on it. If you have any urgent issue about the framework, please let me know what are they. I will try my best to solve them and if possible, give you an advance fix
     
  35. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    thx songtan...
     
  36. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    i notice that the pause button is linked to the menu and option place.....how do u separate the two...
    i want to players to pause the game so they have time to reaction in difficult creeps and build towers.... but their will still be option button that also pauses the game but will have a widow with option like resume, menu and etc like the one u have....
    well all im trying to say is that i just want a button that pauses the game without any windows putting up but also can build towers....
     
  37. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    you can try add this to the UI code.

    Code (csharp):
    1.  
    2.     void OnGUI(){
    3.         if(GUI.Button(new Rect(50, 50, 100, 25), "Pause")){
    4.             if(Time.timeScale<1) Time.timeScale=1;
    5.             else(Time.timeScale>0) Time.timeScale=0;
    6.         }
    7.     }
    8.  
     
  38. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    can make a script for the UInGUI.cs because my UI is going to be base off of Ngui....
     
  39. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    In that case, add following function to your NGUI script:

    Code (csharp):
    1.  
    2.     void PauseGame(){
    3.         if(Time.timeScale<1) Time.timeScale=1;
    4.         else(Time.timeScale>0) Time.timeScale=0;
    5.     }
    6.  
    Then add a button to your UI, then add a UIButtonMessage to the button object. Set the target to the gameObject which the NGUI script is attached to and the functionName to 'PauseGame'. That should do the trick. Tip: Just refer to other NGUI button in the NGUI UI.
     
  40. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    402
    Hi Songtan,

    I want to change the end of level to be after all the waves have spawned and when the final creep dies.

    At the moment the game ends after the final wave has spawned.


    What is the best way to check for this?

    I was looking through the various scripts and could not find any static count for UnitCreeps that count be combined with a test with totalWaveCount in order to check for this.

    Do you have any ideas here?

    thanks

    Nalin
     
  41. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    Sounds like a bug to me. The game is not suppose to be over until the all the creeps (in all waves) has died or reach final waypoint. There should be log message showing the spawning message. Can you please confirm that your game ended as soon as you see "Wave (final) has done spawning". Also could you let me know the following so I can check:

    What are the spawn mode you are using?
    How many waves are there?
    Are you using any splitting creeps?
    Are you using looping path?
    Does the same thing happen in example scene?

    Fyi there are no one totalUnitCount for keep tracking of the creep. Each creep is tracked with respect to their own wave. A wave is cleared when all unit tied to it has died or scored. And a gameover condition check is run only when a wave has been cleared or a creep has scored.
     
  42. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    402
    I have 10 levels, and this happens with all but the first two :( - not been able to track down the difference yet.

    What are the spawn mode you are using? Continuous
    How many waves are there? 2 typically
    Are you using any splitting creeps? No - don't know what this means ;)
    Are you using looping path? No - don't know what this means ;)
    Does the same thing happen in example scene? No - does not seem to

    One thing I did change is that I removed the concept of player's lives as below.

    void OnDeductLife(int waveID){

    // Nalin - no lives in SETD
    //playerLife-=1;
    if(playerLife<=0) playerLife=0;

    if(onLifeE!=null) onLifeE();

    if(playerLife==0){
    //game over, player lost
    gameState=_GameState.Ended;
    if(onGameOverE!=null) onGameOverE(false);
    }
    }

    In the level where this happens there are two waves, each with va single sub-wave and I see the following in the log

    - wave 1 has done spawning

    - wave 1 has done spawning (not sure why this says wave 1 twice)

    - Wave 1 has been cleared

    Then I get the Level Complete dialog - with creeps still marching, and when the last one dies I get

    - Wave 0 has been cleared


    Hope this makes some sense ...

    N
     
  43. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    I'm very sorry for the slow respond.

    I've managed to replicate the error but I'm not sure if that's your case. It happen for me when I deliberately timed two waves to spawn at exactly the same time (by setting "TimeBeforeNextWave" to zero in continous spawn mode). Hence the repeat "wave 1 has done spawning" message. Then I make it so that the all the creeps of the second wave would complete their path ahead of the creeps of first wave.

    Simply put, the level will be completed as soon as the final wave has been cleared, regardless of other level. I suspect your setting has caused just that, the creeps of second wave race ahead and get cleared before the first wave.

    This is certainly an logic error on my end. I'll get it fixed. However it's avoidable. Hence for the time being I would suggest you to re-edit your wave setup. I'm pretty sure merging wave1 and wave2 will fix the issue. Alternatively you could make a sufficient clearing between the spawn time of wave1 and wave2.
     
  44. BeerNuts

    BeerNuts

    Joined:
    Dec 20, 2012
    Posts:
    3
    Any chance we can get a pie build menu for NGUI? On mobile the point and click NGUI menu doesn't work so well considering screen space.
     
  45. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    It will be there in the next update. It's done but it's not polished or tested enough yet.
     
  46. Tsurugi

    Tsurugi

    Joined:
    Sep 21, 2012
    Posts:
    97
    hey songtan...... the only way to cancel the pie chart is when i touch the path or other than the the platform..... can you code the script so when i touch the platform again the pie chart will disappear....

    can you code the wave info display so that the icons stack on each and it will act like a slide show, but still separate the current and next wave box....

    it's possible to use sprite based animations for the creeps and towers instead of 3d animations.
     
    Last edited: Mar 8, 2013
  47. aecampana

    aecampana

    Joined:
    Feb 25, 2013
    Posts:
    1
    Hi Songtan, congratulations on a great job so far.

    Its a Amazing Kit!
     
    Last edited: Mar 8, 2013
  48. Jombobo

    Jombobo

    Joined:
    Mar 9, 2013
    Posts:
    2
    Hi Songtan, have any tutorials about armor , damage,shield(armorType and damageType)? if creep has spell resistances, how do it?
     
  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    @Tsurugi
    The pie chart menu I sent you are pretty much wip. I still havent finalized it as I'm still adding new stuff to the kit. The new addition (player ability specifically) will require me to extend the UI even more. I'll see what I can do about your request, most likely it will work exact the same as it OnGUI() counterpart when done.

    I'm afraid this wont be on my plan. I dont see how it benefit the kit as a whole. And it's too much work for a very small UI polish. Sorry for that.

    I think it would be very tricky to get everything right without actually modding the code and some of the mechanic of the kit.


    @aecampana Thank you very much!


    @Jombobo
    Unfortuantely I dont have any video tutorial yet. But it's actually very simple. let me show you here:

    Say if you have 3 different type of armor (named human, elves and orcs for the sake of example) and 2 different damage (physical and magic). You can set up the DamageArmorTable so it looked as follow:

    $ArmorTableExample.png

    You can then edit the numbers in the table to reflect how each armor affect each damage. According to the images shown,
    human are the neutral, they take full damage from both physical and magic damage.
    Elves however, are vulnerable to physical damage but resistant to magic, they take 25% additonal physical damage and 25% less magic damage.
    Orcs are the opposite of elves, they reduce any physical damage by 50% but suffer 50% more magic damage.

    Once you have this setup, you can then assign the damage type and armor type to each unit in their repective editor (towers in TowerEditor, creeps in Inspector). There should be a variable named armorType and damageType (if the unit can attack) for each of the unit type. The variable are integer type which mean it takes values like 0, 1, 2, 3, 4... The number corresponding to each armor or damage type is shown in the table. If you assign a unit the armorType of 0 and damageType of 1, according to the example table in the image, it should have the armor attribute of human and do magic damage. One unit can only have 1 armorType and 1 damageType.

    Also please note that any change you made to the DamageArmorEditor will only take effects after you save it. If you close the editor without saving, all your unsaved change will be lost.
     
  50. webgovernor

    webgovernor

    Joined:
    Feb 10, 2013
    Posts:
    18
    Hey Song,

    I've added a new targeting priority, and thought that you (or others on here) might be interested.

    First, in UnitTower.cs, I added

    Code (csharp):
    1.                         else if(targetPriority==_TargetPriority.Toughest){
    2.                             float hp=0;
    3.                             foreach(Collider col in cols){
    4.                                 targetTemp=col.gameObject.GetComponent<Unit>();
    5.                                 if(targetTemp.HPAttribute.HP>hp){
    6.                                     hp=targetTemp.HPAttribute.HP;
    7.                                     currentTarget=targetTemp;
    8.                                 }
    9.                             }
    10.                             if(currentTarget!=null  currentTarget.HPAttribute.HP>0) target=currentTarget;
    11.                         }
    12.                         // Added the below else if statement
    13.                         else if(targetPriority == _TargetPriority.First) {
    14.                             float lastDm = 0;
    15.                             foreach(Collider col in cols){
    16.                                 targetTemp=col.gameObject.GetComponent<Unit>();
    17.                                 if(targetTemp.distanceMoved > lastDm){
    18.                                     currentTarget=targetTemp;
    19.                                     lastDm = targetTemp.distanceMoved;
    20.                                    
    21.                                 }
    22.                             }
    23.                             if(currentTarget!=null  currentTarget.HPAttribute.HP>0) target=currentTarget;  
    24.                         }
    Then, in Unit.cs:Unit(), I added two class properties:

    Code (csharp):
    1.  
    2. public float distanceMoved = 0f;
    3. private Vector3 lastPosition;
    4.  
    Then in Unit():Start() I added:

    Code (csharp):
    1. lastPosition = thisT.position;
    Then in Unit():Update() I added:

    Code (csharp):
    1. distanceMoved += Vector3.Distance(thisT.position, lastPosition);
    2. lastPosition = thisT.position;
    Of course, I updated the Enum in UnitTower for the targeting priority, and then added it to the TowerEditor as well.

    Thanks!