Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

TowerDefense ToolKit 4

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

  1. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    70
    @songtan

    I tried several times now.
    Im using Custom Layout.
    As far as i can see the "Carry Over" function is not working. The perkManager show his:

    2020-12-06_19h18_36.png

    2020-12-06_19h23_37.png

    2020-12-06_19h26_55.png

    but when i enter the campaign map this is what the perkmanager shows:

    2020-12-06_19h19_31.png

    2020-12-06_19h23_37.png

    So its not carrying over perks to main game.
    Im using URP newest version of Unity.
    Is there some components that NEED to be there for the Custom UI
     
  2. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    70
    I did upgrade from Old version to new version. I did import the Old database with all Towers and perks into This new version.
     
  3. ceprowler

    ceprowler

    Joined:
    Oct 24, 2020
    Posts:
    10
    I hope this is not covered already but I was unable to find anything. I have a new type of creep and when it spawns it runs through the platforms with only the top half going over the platform (the bottom under it). I'm unable to raise the creep prefab up. I can raise the path but then it is difficult to get the platform grid to look correct on the material underneath it. I thought perhaps the Terrain object would let me set the creep height but that did not work either. Is there a way to adjust the path offset or is raising the paths the only method to adjust this?
     
  4. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    70
    Hey

    try to Take the demo scene.
    Then dont change anything.

    go to spawn under td and add your unit.

    If its still under the platforms. Then its the unit.
     
    MaxiMaximaal likes this.
  5. MaxiMaximaal

    MaxiMaximaal

    Joined:
    Dec 7, 2019
    Posts:
    11
    What is a good way randomize instantiated prefabs?

    Let’s say I have a few different visuals states for the towers/blocks to make the scene visually more diverse.

    What I tried:

    1. Making 3 separate prefabs of different visuals each with its own Tower Unit Script.

    2. Create GameObject with both the Randomizer & a new Tower Unit Script

    3. Attach/link the 3 prefabs in the Randomizer script

    Currently it’s not a very stable solution, it sometimes already builds the tower when hover over the grid or stacks multiple on each other.

    So what would be the proper way?

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Randomizer : MonoBehaviour
    5. {
    6.     public GameObject[] objects;
    7.     void Start()
    8.     {
    9.         int x = Random.Range(0, objects.Length);
    10.         Instantiate(objects[x], transform.position, Quaternion.identity);
    11.  
    12.     }
    13.  
    14. }
    Found the working solution on this forum:

     
    Last edited: Dec 26, 2020
  6. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    16
    Hello Songtan!

    1. Can you help me please with Save system, as I find in Perk Manager there is already have a code for saving u just comment the Load() and Save() yeap? If I right I didnt see the HighestLVLID save in that code how can I save and load it correctly?

    2. This system work only on awake (Load) and CachedProgress (save) CachedProgress work if player won LVL... I need to add some Save points how can I call Save from Game Controll.cs? (For example then User push Quit button)
     
    Last edited: Dec 18, 2020
  7. thepiratebob

    thepiratebob

    Joined:
    Apr 22, 2018
    Posts:
    5
    Are we removing the Animator from the mesh and creating a child game object for the animator here? Some models have animators already attached. I just got a little confused here. I'm having a similar issue with towers.

    An image of the game object tree would be excitingly helpful.
     
  8. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    70
    Gameobject with collider and UnitCreep attached
    Gameobject called Animator with Animator component. Then use TDUnitController as Controller and what ever avatar works for your animation.
    Apply all meshes below this and bones.

    Save it.

    2020-12-20_13h18_22.png

    2020-12-20_13h18_29.png
     
  9. thepiratebob

    thepiratebob

    Joined:
    Apr 22, 2018
    Posts:
    5
    Thanks a lot. I was attaching the animator in wrong place.
     
    Niroan likes this.
  10. thepiratebob

    thepiratebob

    Joined:
    Apr 22, 2018
    Posts:
    5
    I could just missing something. I'm having trouble getting my fire rate and animations to sync. My shoot object fires faster than my animations.

    Any suggestions?
     
  11. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    70
    There is a delay under tower animation for attack.
    Can you show screenshot of what your trying to archieve?
     
  12. thepiratebob

    thepiratebob

    Joined:
    Apr 22, 2018
    Posts:
    5
    .
    No screen shot needed really.
    My rate of fire on the projectile is much faster than my animation. I'm trying to slow the ROF not the speed of the projectile. If I increase my animation speed. My tower looks as if it is having a seizure.
     
  13. ceprowler

    ceprowler

    Joined:
    Oct 24, 2020
    Posts:
    10

    You can adjust the rate of fire in the tower editor either under delay or under distance between shoot points. If you have multiple shoot points the shoot distance is the time until the next shot to help adjust to your animations. Otherwise I'd just adjust the animation slightly if that doesn't work. I hope that helps.
     
  14. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    16
    Ok load and save system work except purchased perks, and actually I dont have any ideas why... Can someone help me please with that?

    part of PerkManager Code
    Code (CSharp):
    1. private static bool loaded=false;
    2.         public void Load(){
    3.             if(loaded) return;
    4.             loaded=true;
    5.             GameControl.highestLevelID = PlayerPrefs.GetInt("TDTK_HighestLVL");
    6.             rsc=PlayerPrefs.GetInt("TDTK_PerkRsc");
    7.          
    8.             List<int> purchasedPrefabIDList = new List<int>();
    9.             int count=PlayerPrefs.GetInt("TDTK_PerkCount", 0);
    10.             for(int i=0; i<count; i++) purchasedPrefabIDList.Add(PlayerPrefs.GetInt("TDTK_PerkID_"+i, 0));
    11.          
    12.             Debug.Log("load   "+rsc+"    "+purchasedPrefabIDList.Count);
    13.          
    14.             TDTK.OnPerkRscChanged(rsc);
    15.         }
    16.      
    17.         public void Save2(){
    18.             //Debug.Log("save perks  ");
    19.          
    20.             PlayerPrefs.SetInt("TDTK_PerkRsc", GetCachedRsc());
    21.             PlayerPrefs.SetInt("TDTK_HighestLVL", GameControl.highestLevelID);
    22.             List<int> perkList=GetCachedPurchasedIDList();
    23.             PlayerPrefs.SetInt("TDTK_PerkCount", perkList.Count);
    24.             for(int i=0; i<perkList.Count; i++) PlayerPrefs.SetInt("TDTK_PerkID_"+i, perkList[i]);
    25.         }
     
  15. cdr9042

    cdr9042

    Joined:
    Apr 22, 2018
    Posts:
    83
    Hi, I just took a look through the asset. It seems to make a new level, I have to click on Tools/TDTK/New Scene, right?

    So every time I want to make a new level I have to make a new scene?
     
  16. ceprowler

    ceprowler

    Joined:
    Oct 24, 2020
    Posts:
    10
    @ Niki - 4 I haven't messed with the save and load feature but would be interested in the functionality of it if you get it working.

    @ cdr9042 - That is correct you make a new scene per level or an alternative if you have lots of customizations you can do a "SaveAs" and save the existing scene under a new name and just remake / adjust as needed for the next level. Both options seem to work in my experience. I hope that helps!
     
    MaxiMaximaal likes this.
  17. cdr9042

    cdr9042

    Joined:
    Apr 22, 2018
    Posts:
    83
    So what if I want to make a change to all levels? Say, I created 100 levels and now I want to change the lighting setting of the scenes, or add one more component to the controllers, or change camera setting, how do I do that?
     
  18. ceprowler

    ceprowler

    Joined:
    Oct 24, 2020
    Posts:
    10
    Unless you know a trick that I do not then those changes are one at a time... However, if it is something like the UI or Camera often you can copy the component and paste it into each scene to help speed that up a bit. Still takes some work however. Keep in mind some changes are global but most of those are via the built in editors for towers, creeps, perks, etc.

    Disclaimer: I'm not a coder and I've only been using TDTK4 for a few months so it is possible there are tricks to accomplish your goal that I'm not aware of.
     
    cdr9042 likes this.
  19. ceprowler

    ceprowler

    Joined:
    Oct 24, 2020
    Posts:
    10
    Has anyone been able to use the perk abilities to successfully add health or shields to your towers? For some reason it is adding it to the creeps instead of the towers and I'm not sure why. Thank you in advance.

    EDIT: After some testing it seems to be only if I select for the tower modification to be "all towers" if I list them out everything works fine.
     
    Last edited: Dec 25, 2020
  20. MaxiMaximaal

    MaxiMaximaal

    Joined:
    Dec 7, 2019
    Posts:
    11
    Perhaps the most common parts of the TD-TK framework could be kept as Prefabs like CameraControl, AudioManager while others are kept manual/non-prefabs? Should be better on the memory too that way.
     
    ceprowler likes this.
  21. MaxiMaximaal

    MaxiMaximaal

    Joined:
    Dec 7, 2019
    Posts:
    11
    Is it possible to set-up a pre-built Tower Unit as an obstacle that must be destroyed before the creeps can move on? (And not bypassing it in any possible way) Currently they do attack the obstacles but at the same time also walk straight through it following the original path.

    For more context, currently I want to implement in two different ways:

    - A fence/barricade that creeps must attack before they can reach the end point of their path.
    - A final (passive) Unit Tower that’s on the end of the creep’s path that must be fully destroyed by creeps. (If so, it triggers game over.)

    I also tried adding/removing colliders on the obstacles and setting them on layer 26.
     
    Last edited: Dec 26, 2020
  22. razumeichenkoa

    razumeichenkoa

    Joined:
    Oct 23, 2020
    Posts:
    2
    Hi. Is it possible to use two different prefabs (base with legs/chassis and weapon) with two different avatars and one animation controller (TDU)?
     
  23. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    Sorry guys. For some reason I keep missing the notification for new post. I'll try to respond to unanswered questions as best as I can. @Niroan and @ceprowler, thanks for helping me in answer some of the questions.


    Make sure you tower firing rate is not faster than your animation length so the animation has sufficient time to finish before the next attack starts. You can adjust the tower firing rate using the 'cooldown' of the tower prefab. Then if you want to add a delay to when the shoot-object being fired while animation play (if your animation has a 'run up' before the actual 'fire the shot' moment), this can be done in the delay attribute where you assign the attack animation in TowerEditor.


    They key to the Save function you found in TDSave.cs is in the comment. You need to replace purchasedPrefabIDList in PerkManager with the list loaded in Awake(). If you look at PerkManager, Start(), purchasedPrefabIDList is used to unlock the perk (Start() is executed after Awake()). purchasedPrefabIDList is just a list keeping track of the ID of the perk that already been unlocked. On it's own, it doesn't do anything. In short, just add this in PerkManager, Awake().

    Code (csharp):
    1. if(!loaded){
    2.     loaded=true;
    3.     purchasedPrefabIDList=TDSave.LoadPerk()
    4. }


    There are things that work from level to level like lighting. This is by unity's design. Other things like camera, you can use prefab. However these may not always apply. In a lot of games, the design and layout of each level are so drastically different you rarely use a common camera setting. For example, depends on the size of the level, you will need different camera move range limit, different zoom limit, etc.


    For point-1, You can't fully block the path. The system simply doesn't support that. However you can use the 'Can Be Attacked' option on the tower to achieve more or less what you want. You can disable that for all towers except the fence/barricade place at the key point and make sure 'Stop To Attack' is turned on for all creeps. This way the creep will only attack the barricade and they will not progress until they have taken all the barricade in range.

    For point-2, Again you can make sure of the 'Can Be Attacked' option and make sure that key/final tower can be attack. There's a 'Destroyed Life Cost' attribute for the tower. That is the amount of player life lost when the said tower is destroyed by a creep attack. Just set that to match the number of player life in that level (In GameControl).


    Of course. There's only one animator controller in the package (TDUnitController) and it's meant to be used across all prefabs (both towers and creeps).
     
    MaxiMaximaal likes this.
  24. MaxiMaximaal

    MaxiMaximaal

    Joined:
    Dec 7, 2019
    Posts:
    11
    @songtan Thanks! Stop To Attack did the trick! Somehow I did not notice this checkbox before.

    Does anyone know how to link an (weighted) array of Audio/Animation clips instead of a single clip one inside the Creep/Tower editor? So it’s possible to play kind of randomized sounds/animations for the Creeps/Towers, especially for the attack ones.
     
    Last edited: Dec 29, 2020
  25. razumeichenkoa

    razumeichenkoa

    Joined:
    Oct 23, 2020
    Posts:
    2
    razumeichenkoa said:
    Hi. Is it possible to use two different prefabs (base with legs/chassis and weapon) with two different avatars and one animation controller (TDU)?
    Of course. There's only one animator controller in the package (TDUnitController) and it's meant to be used across all prefabs (both towers and creeps).

    I mean i have a creep with two different parts: 1) bottom part of the creep (legs/chassis) with its own avatar and animation; 2) top part of the creep (weapon platform) with its own avatar and animation. Is it possible to use two different avatars with one animation controller (TDU) on one creep?
     
  26. Subzeroblack68

    Subzeroblack68

    Joined:
    Apr 3, 2014
    Posts:
    19
    Just bought the asset. But I was curious about something. Most Tower defense are well... playing on the defensive side.

    But I wanted to know if you can play on the Attacker side of things? Like create a preset Defense level and then you play as the attacker spawning in creeps.

    This wasnt want I bought it for, but though it was an interesting thing to find out if its built in or possible?
     
    Niki-4 and MaxiMaximaal like this.
  27. Niki-4

    Niki-4

    Joined:
    Oct 29, 2017
    Posts:
    16

    Its work Thank you)

    I just simly add

    Code (CSharp):
    1. if(!loaded){
    2.                 loaded=true;
    3.                 purchasedPrefabIDList=TDSave.LoadPerk();
    4.                 GameControl.highestLevelID = TDSave.LoadHighestLvlID();
    5.                 rsc=TDSave.LoadPerkRsc();
    6.             }
    to PerkManager.cs Awake() and thats all)
     
    MaxiMaximaal likes this.
  28. NamelessGames_

    NamelessGames_

    Joined:
    Jun 4, 2019
    Posts:
    25
    I'm using this tool and I'm loving.

    @songtan I'm doing some custom function on this tool, so I'm going to let them know in case you'ld like to add to tool as default (I really think they should be inside this pack). I hope this is the right place for suggestions.

    1. Turrets can attacks multiple targets
      • I could send you the code I've written. It's perfectly integrated with your own code and it doesn't raise any error
    2. Tooltip and descriptions could be dynamic in order to be able to auto update them having not to manually do
      • Example (i): "Tower damage: {dmg_avg}" and {dmg_avg} would be replaced from "(damage_min + damage_max) * 0.5f"
      • Example (ii): "Tower damage: {dmg_min} - {dmg_max}" would be "{dmg_min} => damage_min" and "{dmg_max} => damage_max"
      • I could send you the code I've written. It's perfectly integrated with your own code and it doesn't raise any error. It's not totally completed right now and I'm sure it's a perfect point to start.
    3. Turrets shoud be able to be Support too. I think this option would add a lot of value to this toolkit.
      • I'm going to code it right so I've not to send it actually.
    However it's a really good job, but it couldn't be in other way from Element TD creator!!
     
    Proto-G and MaxiMaximaal like this.
  29. NamelessGames_

    NamelessGames_

    Joined:
    Jun 4, 2019
    Posts:
    25
    I've to add another point:
    1. Turrets should be able to be Support and AOE too. It's unrealistic being one of them at time.
     
  30. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    It's possible. However it's not supported by the current code. To do this you will need to have 2 Animator components, each with their own avatar. You can use the same controller on both of them. The problem is the script assume there's only one Animator. It get a reference to that one animator and send signal to that one animator. So to have this work, a light modification will need to be done so that the script will support multiple animator.


    It does not work right out of the box for that. However, I would say that since most of the key mechanic are there so it shouldn't be too difficult to do a little modification to get something like that to work. The trickiest bit is probably establish how the economy in each scenario works and how a game won/lost state is determined. There's still a lot of design detail you need figure out.


    @ilMale92, Thanks for your suggestion. I wouldn't mind seeing your code and see how I can add that to the base framework. Concerning turret, support and aoe shouldn't be mutual exclusive, I agree. To support this I'm probably going to ditch the tower type system all together for a more flexible system. I'll think about it and see what I can do. Btw I didn't create the original ElementTD. I just work on the standalone version that is ElementTD-2.
     
    NamelessGames_ and MaxiMaximaal like this.
  31. YevgenG

    YevgenG

    Joined:
    Oct 17, 2018
    Posts:
    22
    Hello, @songtan !

    I have a question about the Perk System. I faced an issue when I cannot create a new perk, particularly new tower upgrade. So, I did all the steps as usual, that worked with previous towers:
    1. Create prefabs of a new towers.
    2. Added them to Towers Base.
    3. Added towers of higher level to the "Tower Stats and Upgrades" section.
    4. Tried to create UnlockTowerUpgrade perk.

    As you may see on the attached video Perk creation menu simply doesn't provide an option to choose an upgrade and says "Selected prefab has no upgrade tower", while it certainly does, it can be seen even in the default editor of the tower.

    Please, may you let me know what is possible reason of this behavior and if it can be fixed?

    https://drive.google.com/file/d/1UZW2UaBLvqDXxKMmHvzWs8lR5Sbs9e8Q/view?usp=sharing
     
  32. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    I did a quick test and I'm pretty sure it works. However looking at the code, I think what happen is somehow your tower prefab has end up using a duplicated prefabID. So while the display shows the you have the ice tower selected, the search function in PerkEditor end up selecting another tower prefab with the similar prefabID, one without any next upgrade tower assigned.

    I would suggest you to try manually give the tower another prefabID, something with 5+ digit like 99999 where the default algorithm will never end up using. To do this you will need to select the tower prefab and expand the 'Show Default Inspector' option in Inspector (you should find the slot PrefabID). Then try to edit the perk again once you have done that.
     
  33. MaxiMaximaal

    MaxiMaximaal

    Joined:
    Dec 7, 2019
    Posts:
    11
    Got to ask again:

    How do I link an (weighted) array of Audio/Animation clips instead of a single clip one inside the Creep/Tower editor? So it’s possible to play kind of randomized sounds/animations for the Creeps/Towers, especially for the attack ones.
     
  34. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    You need to modify Unit.cs (for animation) and UnitTower.cs and UnitCreep.cs (for audio), replacing the audio and animation clip with your array. By default, the script will just use the one clip being assigned when the play event is called. You will change the code to select (randomly or use weighted random) one of the clip from the array to play. This is pretty straight-forward for audio as you can easily change the clip to play. The animation however is a little bit more complicated, you will need to refer to the code in InitAnimation() in Unit.cs to see how it's done.
     
  35. MaxiMaximaal

    MaxiMaximaal

    Joined:
    Dec 7, 2019
    Posts:
    11
    I got the randomized soundclips working. The animation clips seem too complex for for me to tackle at the moment.

    Inside UnitCreep

    I changed public AudioClip soundDestroyed; to public AudioClip[] soundDestroyed; to make an array and added this code:
    Code (CSharp):
    1. AudioClip randomSoundDestroyed()
    2.         {
    3.             return soundDestroyed[Random.Range(0, soundDestroyed.Length)];
    4.         }
    and changed
    Code (CSharp):
    1.             if(spawnEffDestroyed){
    2.                 effectDestroyed.Spawn(GetPos(), Quaternion.identity);
    3.                 AudioManager.[B]PlaySound(randomSoundDestroyed()[/B]);
    4.             }
    Unfortunately this seems to break the CreepEditor, as both the Animation And Audio field are invisible. So in order to add the clips it has to be done in the default Unity UI, but it works.
     
  36. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    The editor windows has their own scripts (they are located in Assets/TDTK/Scripts/Editor). If you want your modification to show up on them, you need to modify those script as well. For CreepEditor, the script in question is W_UnitCreepEditor. It's optional of course, you can just use the Inspector instead if it's too much trouble.
     
  37. YevgenG

    YevgenG

    Joined:
    Oct 17, 2018
    Posts:
    22
    Hello, @songtan !

    Thanks a lot for your advice to set Tower Prefab ID manually to fix an issue with a Perk to unlock new tower upgrade. Unfortunately, it didn't help :( Even more, when I did so, perk manager breaks into some veird state... While for other towers it works.

    The difference between these towers, perhaps, is that some of them were created for a long time ago (in the Towers List) and these new Ice towers - only recently. Can this be the reason? Even more, I tried completely new prefabs, that never were used in this build, and they have the same issue... Maybe I should re-import some assets to the project?..

    Please, see some additional video below:
    https://drive.google.com/file/d/1jGgCf-jUFGeZpTDxFbIHxeJHA3jw93VZ/view?usp=sharing
     
  38. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    I have to ask, when the PerkEditor breaks, do you see any error message in the console window? There should be some according to the code I've. Can you let me know what are the full error message?

    I don't think the problem is the towers being created recently or before. It has to be something to do with some of the settings on the tower prefab or perk. I've just tried this with a new tower prefab and everything seems to be working.

    One thing that we could do, if you don't mind, is for you to send me your DB files (those in Resource folder) and all your tower prefabs so I can check.
     
  39. YevgenG

    YevgenG

    Joined:
    Oct 17, 2018
    Posts:
    22
    Hey, @songtan !

    Here is the message from the console:
    upload_2021-1-14_13-43-48.png

    And Towers prefab and databases :)
     

    Attached Files:

  40. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    Are you using the latest version or have you don any modification to the scripts? From the error it looks like your script is different from the default copy from AssetStore.

    Also I'm afraid the files doesn't work that way. You will have to export it to a unity package. And I'll need all your tower prefabs. Not just the ice tower. The good news is you can leave out all the textures, meshes, audio-files and icons to keep the package size small.
     
  41. MaxiMaximaal

    MaxiMaximaal

    Joined:
    Dec 7, 2019
    Posts:
    11
    Where/how do I assign a certain material / texture for previewing/positioning towers (and perhaps a separate one for building) like most RTS games do?
     
  42. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    At the moment, I'm afraid it's not possible unless you do some code modification. The drag and drop preview towers are the instances of tower in sampleList, created in TowerManager Awake(). You can assign the alternate material for the towers and have them activated for those preview towers.
     
  43. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    Hi everyone, I've just pushed an update (v4.1) to AssetStore. Just want to gives everyone a heads up that it's a fairly big update with some significant changes.

    I've added support for unit with multiple roles. That means a unit can be a turret, aoe, support, resource generator, mine, and spawner (for creep), all at the same time. For that I have to restructure the stats, creating a block for each of those function. Now this won't break your existing setting. But you will need to manually adjust the stats on your tower and creep prefabs, as well as perks to make sure they have the right value. So please don't freak out if right after the update your aoe or support tower doesn't work correctly.

    Thanks to @NamelessGames_ for suggesting this in the first place.
     
  44. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    It's just another resource type. It doesn't do anything unless one of the tower, ability or perk requires it.
     
  45. HajiyevEl

    HajiyevEl

    Joined:
    Feb 19, 2020
    Posts:
    31
    Thanks, already solved it.
    Can you please give me advice on how can i make turrets fire ability? Like when i press on turret i want it to use ability assigned to it, is it possible?
     
  46. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    I'm afraid that is not possible. The abilities are not tied to the towers.
     
  47. HajiyevEl

    HajiyevEl

    Joined:
    Feb 19, 2020
    Posts:
    31
    Alright, thanks for answer!
     
  48. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    178
    I would like to use the capped player life as a resource.

    Idea:
    Under GameControl I want the player's life capped @ 50
    I want to use the 50 life points as a resource for the player to use for building towers. But when they sell the towers, I want the resource to go back into players life value. So this will create a balance where the player must manage resources wisely.

    Is this simple to achieve? How would I achieve this?
    -Thx
     
  49. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,749
    Should be fairly simple. In TowerManager.BuildTower() (in TowerManager.cs), the method used to build tower in game, there's a resource check before the tower is built. You can add a similar check for player life. Just use GameControl.GetLife() to get the value of player life, and GameControl.LostLife() to deduct player life. For when a tower is destroyed, you can simply add GameControl.GainLife() in Destroyed() in UnitTower.cs.

    Hope this help.
     
    Proto-G likes this.
  50. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    178
    Not fairly simple for me lol. Thanks for reply and quick response!
     
unityunity