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
  2. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Make sure the TowerList in your Tower_DB is in order. That you have a Tower_DB in Resources folder. There's a list on it and there's no empty element.

    upload_2023-3-23_12-16-21.png
     
    darknside likes this.
  3. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
  4. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
  5. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Just fyi, while I code almost all of the game, the multiplayer net code is someone else department entirely. It's a blackbox to me as far as I'm concern. So I'm still very much clueless when it comes to multiplayer networking. Sorry to disappoint.
     
    toddkc likes this.
  6. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    My post was joking, not disappointed at all. Looking forward to playing Axon! I'm sure it'll be great.
     
  7. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thank! I'm mostly just disappointed at myself for not having the will power to learn it.
     
    toddkc likes this.
  8. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    I mean...you indirectly taught me C#, so I refuse to believe you couldn't learn it if you wanted to. Unity has lots of great tools for multiplayer: Photon PUN and Fusion, Mirror, FishNet, and many more.
     
  9. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I know what you mean. It's just something I'm not that interested in.
     
  10. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    Nothin wrong with that. Do what you love.
     
  11. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    That's not how this wave generator works. While you have enable french-fries after wave 4, there's only a small chancee that it will spawn. And that chance is diminishing every wave. The problem is your Odds value. The spawn chance of each unit is 100x(odd value/sum of odd value of all the enabled units). So in your case, french-fries spawn chance in first wave is 6/(20+6), second wave - 6/(35+6), third wave 6/(50+6), and so on.

    And I'm not sure you want Sugar to keep spawning after wave-4, but there's no way to make sure french-fries get spawned for certain in wave-4 without disabling Sugar after that.
     
    darknside likes this.
  12. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Well what you need to understand that the procedural wave generator uses randomization. So while what you want is possible, there's always going to be some chance involved and you end up getting something else.

    If you want a specific enemies to show up in specific waves, you will have to manually configure the wave composition.
     
    darknside likes this.
  13. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    No. I mean don't use procedural wave generation and use the default editor. You can manually set up what to spawn and when.

    upload_2023-4-12_12-10-16.png
     
    darknside likes this.
  14. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You can try play with the dynamic offset value on the path. That will scramble the creep placement for a bit. However by default it's only randomize the position in x and z axis. For your camera angle, you might need to change the code a bit so it works on y-axis as well. You can do that in UnitCreep.cs, Init().
     
    darknside likes this.
  15. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The wave only auto starts if you enable the 'Start On Timer' option on SpawnEditor. If you have it disabled and the game still auto starts, then I'm not sure what happen. You must have done custom modification that causes that.
     
    darknside likes this.
  16. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Change the SpawnCDType to None. I suggest you use the SpawnEditorWindow. You can hover over the option and a tooltip will explain what each option do.

    upload_2023-4-18_23-21-3.png
     
    darknside and Proto-G like this.
  17. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Yes. There's a 'SpawnOnDestroyed' option for the creep prefab on the SpawnEditor.
     
    darknside likes this.
  18. danosono

    danosono

    Joined:
    Jan 22, 2019
    Posts:
    45
    Hello Song_Tan!
    I am looking for SpawnManager.OnWaveStart or something.
    I want to start game music when the wave starts.

    I may also want to play some ambiance sounds when there is no wave currently active.

    Thanks!
     
  19. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You are looking for SpawnManager.SpawnNextWave() for when the wave starts.

    For when a wave end, it's somewhere in SpawnManager.CreepDestroyed(). Look for the debug for wave cleared. You cant miss it.
     
  20. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Unfortunately no. The closest thing you have with the default, unmodified framework is the perk point. Anything other than that, you will have to write it yourself.
     
    darknside likes this.
  21. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Check the RscGainOnWin and PerkRscGainOnWin settings on GameControl. Those are the resource given to the player if they win. If you enable persistent perk progress, then the player can use the resource they gain on winning to unlock more perk.
     
    darknside likes this.
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There's nothing special about the Tower and Creep Editor in TDTK. It's just standard Unity Editor Window. Just search for "unity custom editor window".
     
    darknside likes this.
  23. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You missunderstood. What I meant is they are written using standard scripting API for custom editor window. They are custom scripts written from scratch to edit the items in TDTK. If you want to save your own custom data, you will to write your own custom editor script yourself.
     
  24. danosono

    danosono

    Joined:
    Jan 22, 2019
    Posts:
    45
    Good morning!

    In the TDTK AudioManager, I have separate audio files for Build Start / Build Complete and Upgrade Start / Upgrade Complete but, when a tower is upgraded, the build sounds are played rather than the upgrade sounds.

    upload_2023-5-9_7-50-53.png


    Upgrading as below:


    My versions:


    Any idea why this is happening?

    Thanks!
     
  25. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    It's a bug when you upgrade from one tower prefab to another. I've send you a fix. Please check your inbox.
     
  26. danosono

    danosono

    Joined:
    Jan 22, 2019
    Posts:
    45
    I am subscribing to onLifeChangedE to play an FX with sound when a creep reaches the destination.
    This is working but I wondered if it will also fire if the player gains a life or another situation.
    Is this the right way to go about it?


    private void OnEnable()
    {
    TDTK.TDTK.onLifeChangedE += LifeLost;
    }


    Thanks!
     
  27. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Yes. But the FX will play anytime the value of life changes, not just when a creep reaches the destination.
     
  28. danosono

    danosono

    Joined:
    Jan 22, 2019
    Posts:
    45
    Just wishlist'ed Axon TD: Uprising!
    Looks a mazing!
     
    thefreik likes this.
  29. danosono

    danosono

    Joined:
    Jan 22, 2019
    Posts:
    45
    What is the way to make the bullet do damage to creeps in its range rather than the tower? Like a rocket would do area damage upon exploding on a creep and do damage to surrounding creeps.

    Anything to do with Damage Type on the Tower Editor?
    upload_2023-5-13_9-49-47.png

    Thanks!
     
  30. thefreik

    thefreik

    Joined:
    Sep 9, 2016
    Posts:
    4
    Hey Song!

    I've noticed that my towers and creep are shrinking and becoming weird everytime they respawn. I think it's because their values are not reset when they are pooled. But I've also noticed that this persists through restart. Certain gameobject keep shrinking between plays :S

    And some feedback from an artist-dev, just enable animations on everything even if you think it might be unnecessary :D Animations give so much life to a game, even if it's just a mine (you might want to animate it flying up in the air when it gets destroyed or something). Better to have the option to crank up the juice on everything :)
     
  31. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    For anyone using URP, here's the modified Custom Overlay shader code.
    Code (CSharp):
    1. Shader "Custom/BlendColorsOverlayTexture" {
    2.     Properties {
    3.         _Color1 ("Color1", Color) = (1,1,1,1)
    4.         _Color2 ("Color2", Color) = (0.5,0.5,0.5,1)
    5.         _MaskTex ("Mask (A)", 2D) = "white" {}
    6.         _MainTex ("Detail", 2D) = "white" {}
    7.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
    8.         _Metallic ("Metallic", Range(0,1)) = 0.0
    9.     }
    10.     SubShader {
    11.         Tags { "RenderType"="Opaque" }
    12.         LOD 200
    13.  
    14.         Pass {
    15.             HLSLPROGRAM
    16.             #pragma vertex vert
    17.             #pragma fragment frag
    18.             #pragma target 3.0
    19.  
    20.             #include "UnityCG.cginc"
    21.  
    22.             struct appdata {
    23.                 float4 vertex : POSITION;
    24.                 float2 uv : TEXCOORD0;
    25.             };
    26.  
    27.             struct v2f {
    28.                 float2 uv : TEXCOORD0;
    29.                 UNITY_FOG_COORDS(1)
    30.                 float4 vertex : SV_POSITION;
    31.             };
    32.  
    33.             sampler2D _MainTex;
    34.             sampler2D _MaskTex;
    35.  
    36.             half _Glossiness;
    37.             half _Metallic;
    38.             fixed4 _Color1;
    39.             fixed4 _Color2;
    40.  
    41.             v2f vert (appdata v) {
    42.                 v2f o;
    43.                 o.vertex = UnityObjectToClipPos(v.vertex);
    44.                 o.uv = v.uv;
    45.                 UNITY_TRANSFER_FOG(o, o.vertex);
    46.                 return o;
    47.             }
    48.  
    49.             fixed4 frag (v2f i) : SV_Target {
    50.                 fixed alpha = tex2D(_MaskTex, i.uv).a;
    51.                 fixed3 color = lerp(_Color1.rgb, _Color2.rgb, alpha).rgb;
    52.                 fixed4 detail = tex2D(_MainTex, i.uv);
    53.                 color = lerp(color, detail.rgb, detail.a);
    54.                 fixed4 outputColor;
    55.                 outputColor.rgb = color;
    56.                 outputColor.a = 1;
    57.                 return outputColor;
    58.             }
    59.             ENDHLSL
    60.         }
    61.     }
    62.     FallBack "Diffuse"
    63. }
     
  32. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    Was just looking back through and if anyone's interested I updated the SlaveManager to be more of a Manager.
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. [System.Serializable]
    5. public class TargetSlavePair
    6. {
    7.     public Transform target;
    8.     public Transform slave;
    9. }
    10.  
    11. [System.Serializable]
    12. public class TowerPair
    13. {
    14.     public string towerName;
    15.     public List<TargetSlavePair> targetSlavePairs = new List<TargetSlavePair>();
    16. }
    17.  
    18. public class SlaveManager : MonoBehaviour
    19. {
    20.     public List<TowerPair> towerPairs = new List<TowerPair>();
    21.  
    22.     void Update()
    23.     {
    24.         foreach (TowerPair towerPair in towerPairs)
    25.         {
    26.             string towerName = towerPair.towerName;
    27.             List<TargetSlavePair> targetSlavePairs = towerPair.targetSlavePairs;
    28.  
    29.             foreach (TargetSlavePair pair in targetSlavePairs)
    30.             {
    31.                 Transform target = pair.target;
    32.                 Transform slave = pair.slave;
    33.  
    34.                 slave.localRotation = target.localRotation;
    35.             }
    36.         }
    37.     }
    38. }
     
  33. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    I think this is what he's talking about:
    Code (CSharp):
    1. float angle=Vector3.Angle(dir1, dir2);
    2.            
    3.             return new Vector3(-dir.z, 0, dir.x)*pathOffset*(1+Mathf.Min(1, (angle/90f))*.4142f);
     
  34. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
     

    Attached Files:

  35. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    Search Unit.cs for targetingFOV
     

    Attached Files:

  36. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    Didn't realize this is compatible for use with 2D
     
  37. ozziechan

    ozziechan

    Joined:
    May 13, 2020
    Posts:
    1
    Some progress......


    I have creeps replaced (not in the video linked) and this weekend I'll be replacing towers.... I look forward to the struggles lol.

    Thank's @Song_Tan -Wonderful asset for a noob like myself. Allows me to create stuff I wouldn't have thought possible with limited resources/solo/skillset, and it's appreciated.

    1 quick question- Is there any quick way built in to the template that would allow me to show the resources gained when a unit is destroyed in the same way that damage is currently displayed over the unit? Or would that be something custom?

    Thanks.
     
    toddkc likes this.
  38. BellokTV

    BellokTV

    Joined:
    Dec 14, 2018
    Posts:
    19
    my turret pivot assignments keep getting reset randomly even when I am not working on the specific tower that gets reset. This is extremely aggravating as the tower turrets will randomly stop targetting things or fail to rotate until I reset the setting manually... I keep having to reset them over and over... please fix it as I have not changed any code at all and the only other assets imported are the tower prefabs I am using.

    It also resets if you make any changes to stuff like the icon. That is also annoying, but just a QOL thing. If we haven't changed the prefab assigned, then the rest should stay the same...

    Here's a video reproducing the issue.
     
    Last edited: Jun 26, 2023
  39. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    On the forum it seems so.
     
  40. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    After this many years I cannot imagine they would just bail with no notice. They recently announced their game, Axon TD, probably just busy with that.
     
  41. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Sorry for not responding folks. I missed a notification somewhere. Plus I'm extra busy than usual I forgot to do my regular check. I believe I've responded to some of the post here via email. Anyway...

    @darknside, the script in question is W_UnitTowerEditor.cs. To add your own field, you will have to modify that. Fair warning: this is going to be a bit difficult unless you are pretty comfortable with coding. You can find all the reference you need here: https://docs.unity3d.com/ScriptReference/EditorGUI.html. And a simple tutorial if you need it - https://learn.unity.com/tutorial/editor-scripting?uv=2018.1#.
     
    darknside likes this.
  42. sayedstafa

    sayedstafa

    Joined:
    Feb 21, 2014
    Posts:
    3
    @Song_Tan
    upload_2023-8-30_18-39-44.png
    I'm having an issue with some towers not being able to deploy.

    I copied the tower prefabs from TDTK/Prefabs/Towers and put the copies into my own folder so that I can make changes to the duplicates and keep the originals intact.

    I added the copies to the Tower Editor list, and two of the towers are no deploying. The Machine Gun and the Laser Tower. For some reason, those two towers are not deploying and I have been tinkering around with the settings to try to see why they wont deploy but I can't figure it out. They are literally just duplicates of the original prefabs. The other duplicates deploy fine and the originals deploy fine but I can't figure out these two. I would appreciate any help.
     
  43. chun1617

    chun1617

    Joined:
    Sep 9, 2023
    Posts:
    1
    Hello Song, Can you screenshot about how to make creep animation?
    I tried to add Clip move animation in "Animation Setting" but it doesn't have anything happen.
     
  44. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    115
    Is it possible to make a tower shoot piercing attack somehow?
     
  45. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You will have to elaborate what do you mean by piercing attack. It means different things in different game.
     
    Niroan likes this.
  46. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    115
    Hi Song

    By piercing i mean bullets flying trough the enemy. So if it had piercing 2 Then it would hit 2 enemies before it exploded or Got Removed. And so on.

    Like hitting in a Line Then depending on How much piercing your Towers have it could hit more and more enemies. Would be a Nice gane mechanic for Any td game.

    i have chain attack where they jump depending on skills but not This.
     
  47. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Not without code modification I'm afraid. The way shoot-object works in TDTK is each shoot-object is fixed on a target. When they hit, they just hit on the target. The piercing that you refer to frankly require another kind of implementation, where a trajectory is determined and then a check is perform to see how many target is hit along the way.
     
    Niroan likes this.
  48. Niroan

    Niroan

    Joined:
    Jun 16, 2019
    Posts:
    115
    Yeah, Your right. I think we can use AOE radius to act the same way sort of, if we control it correctly.
    Btw. Congrats on your new game, looks fun. Watched a youtuber play it hehe.
     
  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Thank you!
     
  50. Riviere_N

    Riviere_N

    Joined:
    Jul 14, 2022
    Posts:
    9
    Hi Song Tan and team,

    I just finished some customisation of the TDTK package:

    Added a custom save

    Modified the powers to have some work as Abilities while others are to be built-in platforms

    I’ve created an infantry-type tower with sentries that patrol the tower on the lookout for creeps, etc.

    My question is related to animations: The manual says to replace any of my FBX/Prefabs ‘animation controllers’ with the Controller included in TDTK (TDUnitController).

    But animations are wrecking my brain.

    So far, I can't get consistent results.

    A) Some of my custom tower animations & controllers work correctly, without ever using the default controller.

    B) Some of the animations don’t regardless if:

    a. I use my custom controller with custom animations and the animations listed in the towerEditor, nor if

    b. I use the default controller with custom animations and the animations listed in the towerEditor, nor if

    c. I use the default controller and only declare the custom animations in the tower editor.

    What is the method TDTK is expecting the animations to be structured?