Search Unity

TowerDefense ToolKit 4

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

  1. GaggiGamer

    GaggiGamer

    Joined:
    Aug 10, 2020
    Posts:
    14
    I added a new resource in RscManager but it is resulting in this error @Song_Tan
     

    Attached Files:

  2. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Are you using the latest version? Check your UITooltip.cs, line70. It should look like this:

    rscItemList.SetLabel(i<cost.Count ? cost.ToString("f0") : "0");
     
  3. GaggiGamer

    GaggiGamer

    Joined:
    Aug 10, 2020
    Posts:
    14
    Oops! I updated already but somehow it didn't overwrite the existing version. So, I re-downloaded it and it worked. Thanks @Song_Tan
     
  4. GaggiGamer

    GaggiGamer

    Joined:
    Aug 10, 2020
    Posts:
    14
    there's a new error for me in UIPerkScreen script in line 144, It was working totally fine before.
     

    Attached Files:

  5. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Try change it to the following (the bold section being the added code):

    if(itemList.image2!=null) itemList.image2.gameObject.SetActive(!purchased && !PerkManager.GetPerkFromList(itemList.linkedPerkIdx).IsAvailable());
     
  6. GaggiGamer

    GaggiGamer

    Joined:
    Aug 10, 2020
    Posts:
    14
    ok, @Song_Tan looks like I'm doing something wrong while adding a new resource. I'm adding a new resource to use it for perks. Everything else seems fine but the time I place the support tower beside some other tower it results into following error :
     

    Attached Files:

  7. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Unfortunately, it's a bug. I'll send you a fix via to your inbox. Sorry for the trouble.
     
  8. GaggiGamer

    GaggiGamer

    Joined:
    Aug 10, 2020
    Posts:
    14
    did you got the solution ?
     
  9. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm pretty sure I've sent you a package containing the fix. Check your inbox.
     
  10. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    302
    I wonder what are the main differences between TDTK-3 and TDTK-4. (ignore the fps part)
    I was just playing around with both on the new unsupported Unity 2022.2.x

    And found that TDTK-3 demo scenes runs perfectly fine, while TDTK-4 demo scenes crashes after a while.
    No real suspect found to the crashes yet, and I'm not really worried, not working on a project just playing around
    with them.

    And even though you write in the asset store that TDTK-3 is discontinued, it's the only one i can get to run smoothly in the next generation of unity :D

    FYI: it's fine in LTS, it's just for next gen unity it's not fine anymore.
     
    Last edited: Jan 5, 2023
  11. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    By discontinued I meant I won't be updating it. But yes as far as I know TDTK3 works just fine on all later version of Unity.

    The biggest difference between TDTK3 and TDTK4 are the code. Mostly behind the scene stuff. TDTK4 is also more powerful when it comes to the path and perk system. And of course I've added a lot of little things since TDTK4 first release so there are plenty of little details that TDTK3 don't have.
     
  12. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    302
    Was messing around with TDTK4 just now and posted a video with it, gameplay from 18:00 in, around 18:20 i found a issue, i want to move the pivot point for the camera, because aparently it's at 0,0,0 but since i have raised terrain i want to move the pivot up, but aparently moving it physically didn't work, but i guess once i am done with camera setup i could just drop it back into the TDTK gameobject, and it would realign to center on the "arena" rather than below.. Just a guess.

    Maybe you have another tip, on moving the pivot point?

     
  13. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I don't really understand the problem. There's no limit to where the pivot should be. Right at 18:00, you set the pivot back to (0, 0, 0). I'm guessing if you haven't done that and just play from that point on, you would have got what you need.
     
  14. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    302

    No worries found out it was offset by myself. ;)

    Another Question.
    Is it not possible to completely disable Parks and Abilites, I tried just removing them from the menues, but that just causes either nullreference errors because they are not there. so it put them back.
    Then i tried just removing the UI buttons or canvas for them, but then the UI causes issues.

    Surely it must be able to just remove those two things? Maybe i am just missing a check mark, i can't find it in the pdf..
     
  15. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Just deactivate PerkManager and AbilityManager in the scene.
     
  16. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You should be able to get everything works in 2D. The game logic should work right out of the box. However, since the framework is made to work in 3D space, the units rotates. If you want your 2D sprites to face the camera, you might have to do a few tweaks. You can either add a script to get your sprite to self-adjust and always face the camera. Or you can modify the code in TDTK so that the unit don't rotate at all. Hope this helps.
     
  17. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    12
    Hello, I have a question for you. There are 2 different buttons, one is new game and the other is load game. I'm making the new game, it's easy. load game is also challenging me. I have little coding knowledge. Do you have a video or how to do it? If I need to code, do you have similar examples?
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You mean saving and loading game? Unfortunately there's no one fix solution for this. There are many different design and implementation of a save/load system. It's not really something that can be explained in a short video.
     
  19. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    12
    My camera moves without limits. a certain movement limit on mobile what should i do
     
  20. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Make sure you enable the 'Enable Limit' option on the CameraControl_Pivot in the scene.

    I'm afraid like save/load system, there's no one simple fix for 2D conversion. Depends on the camera angle and type of sprite you want to use, you will need different code. You can try disable all transform rotation on the towers and the creeps. That's a start. To do for towers, just don't give them any turret and barrel pivot. For the creeps, just uncheck the 'Face Traveling Dir' option on the creep prefab.
     
    gabrifu01 likes this.
  21. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    12
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm not sure if I understand your question. If you mean why the camera stays with the map, Well that's because the camera is part of the TDTK transform hierarchy, moving TDTK transform is of course going to move the camera too. If you mean why the camera bounding box (the green box in the video) does not move with the camera, that's because the limit is centered around (0, 0, 0). It's not based on the position of the camera.
     
    gabrifu01 likes this.
  23. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    12
    Hello, I have 2 questions.
    1) will there be an update - If it does, what may come
    2) Is there a Discord server?
     
  24. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There's won't be any major update in the foreseeable future. I might still do minor update that fix critical bug, if there's any.

    I don't have a discord server unfortunately.
     
    gabrifu01 likes this.
  25. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    12
    Changing some icons in the HUD. While I can change the life and wave icons I cant seem to change the cash icon. In the scene view it shows my new cash icon but when I start the game it changes back to the supplied icon.
    FIXED THIS ISSUE
    Chang the money icon from GameControl
     
    Last edited: Jan 21, 2023
  26. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid I don't understand. Your first image is broken. Your second image while visible, doesn't really help me understand what's wrong. First I need to see the first error that in the console, and I need to know the full error message. Meaning you have to select it so I can see it.
     
  27. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm guessing you arrange the scene in such a way that the camera is looking towards either z or x-axis? Fyi, the platform will always aligned itself with the horizontal plane (x-z). So if you want the camera to align to the platform, you need to rotate the camera, not the platform. You will need to do that for your unit as well, make sure their sprite face upwards (towards +ve y-axis).

    I don't really get the pivot. You mean the tower sprite is not centred around the transform itself? I'm not sure about your tower hierarchy and how you setup your sprite but I would make a the sprite a child of the prefab. Then you are free to adjust the position of the sprite in relation to the root prefab.
     
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I really don't understand the problem. Please send me a screenshot of your scene view with the camera selected. Just like this example image I have below (in the same angle). I need to see how you setup your scene, how you position your camera, what it is showing and so on.

    upload_2023-1-24_9-6-10.png
     
  29. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You need to change your camera orientation to top down. Like this (note the camera rotation):

    upload_2023-1-24_17-33-14.png
     
  30. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Have you change the name of the gameobject in UI/UICamera_Screen/Canvas_HUD/UIHUD/LayoutControl/PerkRscItem? Specifically Image. Most of the element in the UI are name sensitive. I'm guessing you have changed the name that the code cant located the image component.

    Doesn't seem like your change is the issue. There isn't even a Text component in the AbilityManager.cs to start with. The problem is you haven't assign the transform tgtSelectIndicator to AbilityManager in the scene. If you are using the default prefab scene. You must have broken the link accidentally.
     
  31. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    12
    Hello . I plan to do this. When you watch the award-winning ad, it gives energy (what I call energy, for health, briefly for ability), what do I need to add, I don't have any code information. you are more experienced
    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using GoogleMobileAds.Api;
    5. using UnityEngine;
    6.  
    7. public class AdScript : MonoBehaviour
    8. {
    9.  
    10.     private InterstitialAd interstitial_Ad;
    11.     private RewardedAd rewardedAd;
    12.  
    13.     private string interstitial_Ad_ID;
    14.     private string rewardedAd_ID;
    15.  
    16.     void Start()
    17.     {
    18.         interstitial_Ad_ID = "ca-app-pub-3940256099942544/1033173712";
    19.         rewardedAd_ID = "ca-app-pub-3940256099942544/5224354917";
    20.  
    21.         MobileAds.Initialize(initStatus => { });
    22.  
    23.         RequestInterstitial();
    24.         RequestRewardedVideo();
    25.  
    26.     }
    27.  
    28.     private void RequestInterstitial()
    29.     {
    30.         interstitial_Ad = new InterstitialAd(interstitial_Ad_ID);
    31.         interstitial_Ad.OnAdLoaded += HandleOnAdLoaded;
    32.         AdRequest request = new AdRequest.Builder().Build();
    33.         interstitial_Ad.LoadAd(request);
    34.     }
    35.  
    36.     private void RequestRewardedVideo()
    37.     {
    38.         rewardedAd = new RewardedAd(rewardedAd_ID);
    39.         rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
    40.         rewardedAd.OnAdClosed += HandleRewardedAdClosed;
    41.         rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;
    42.         AdRequest request = new AdRequest.Builder().Build();
    43.         rewardedAd.LoadAd(request);
    44.     }
    45.  
    46.     public void ShowInterstitial()
    47.     {
    48.         if (interstitial_Ad.IsLoaded())
    49.         {
    50.             interstitial_Ad.Show();
    51.             RequestInterstitial();
    52.  
    53.         }
    54.  
    55.     }
    56.  
    57.     public void ShowRewardedVideo()
    58.     {
    59.         if (rewardedAd != null)
    60.         {
    61.             rewardedAd.Show((Reward reward) =>
    62.             {
    63.                
    64.  
    65.             });
    66.         }
    67.         else
    68.         {
    69.         }
    70.     }
    71.  
    72.     public void HandleOnAdLoaded(object sender, EventArgs args)
    73.     {
    74.        
    75.  
    76.     }
    77.  
    78.     public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args)
    79.     {
    80.         RequestRewardedVideo();
    81.     }
    82.  
    83.     public void HandleRewardedAdClosed(object sender, EventArgs args)
    84.     {
    85.         RequestRewardedVideo();
    86.     }
    87.  
    88.     public void HandleUserEarnedReward(object sender, Reward args)
    89.     {
    90.         RequestRewardedVideo();
    91.     }
    92. }
     
  32. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I have to say I'm not familiar with ads integration and I'm not sure where you got this script from. Have you modified the script in anyway. Got to say all three HandleRewardedAdFailedToShow(), HandleRewardedAdClosed(), HandleUserEarnedReward() call RequestRewardedVideo() doesn't seem right to me. Assume the script works, My guess is HandleRewardedAdClosed() is the callback for when users finish watching the ads so that's where you call TDTK function to give player additional resource/health.
     
  33. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    12
    I didn't play, so how do I call this function? do you have an example? So I have to say, my biggest problem is, there's an RSC currency in the game, how do I write it? GainRsc doesn't detect this currency when it's written in the currency. ( my english is bad ) :)
     
  34. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm sorry but I don't understand. Yes the resource in the game is added by calling RscManager.GainRsc(), passing the list of the resource gained. Let's say you have 2 type resources in the game (as you configure in RscManager), if you want give player additional 20 resource-1 and 10 resource-2, this is the code - RscManagerGainRsc(new List<int>{ 20, 10 };. It's vital that the length of the list matches the number of resource in your game otherwise it won't work.
     
  35. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The detection radius is actually 3D. It's just that the indicator are shown in 2D along the horizontal plane (xz). You shouldn't have to worry about it if you have set your camera to top down view.
     
  36. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I assume the UIBuildButton object that you have deactivated one are the default one? Just look at the child transform in the 'Button' object in that one. Every child in that button is mandatory and is name sensitive. The code determine which child object in the button is what (image, text, mask) based on their name. When you create your own that don't follow the naming convention, the code can't find those object. So the error you have there is the code telling you there's no image for the button. Now if you want the button to have icons of your tower, you can create a ui-image object for the button (named it as Image). If not, you can just disable line61 and 62 of UIBuildButton.cs.

    I take it by 'canvas of groups 0' you mean the alpha value of the CanvasGroup. Actually that depends on the 'Tower Build Mode' setting on the UI. When using 'PointNBuild', the buttons are meant to be hidden until the player click on a build spot. If you have it set to 'DragNDrop', the alpha value will be set to 1.
     
  37. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    12
    normally tanks come from one place. do we have the possibility to take this out of two places at the same time? . how?
     
  38. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    @gabrifu01, If you want 2 spawn points, just have 2 paths in the scene and have the creep to spawn from both of them. In SpawnEditor, you can set which path the creeps spawned from.

    @darknside, As you can see, it's getting the object by name matching. So if you are to keep your current hierarchy and objects name, change the line you highlighted to this:

    if(child.name=="Mask"){
    foreach(Transform subChild in child){
    if(child.name=="Character"){
    image=subChild.GetComponent<Image>();
    }
    }
    }

    Keep in mind this applies for all UIObject in the UI. So if you do this, All the default button that uses image will break.
     
  39. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    No you are not following. I said change the line you highlighted (line31) to the one I show you. It should look like this:
    Code (CSharp):
    1. foreach(Transform child in rectT){
    2.     if(child.name=="Mask"){
    3.         foreach(Transform subChild in child){
    4.             if(child.name=="Character"){
    5.                 image=subChild.GetComponent<Image>();
    6.             }
    7.         }
    8.     }
    9. }
     
  40. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I don't create the buttons right from the start because there are instances where a tower is added half way through the game. So here's a better way to do what you want without breaking the default UIObject. Just modify the default AddBuildButton() in UIBuildButton to this: (note that I didn't include the whole function)

    Code (CSharp):
    1.     private void AddBuildButton(int idx, Sprite icon, string txt){
    2.         buildButtons.Add(UIButton.Clone(buttonPrefab, "Button"+(idx)));
    3.         buildButtons[idx].rootObj.SetActive(true);
    4.         buildButtons[idx].Init();
    5.        
    6.         foreach(Transform child in buildButtons[idx].rectT){
    7.             if(child.name=="Mask"){
    8.                 foreach(Transform subChild in child){
    9.                     if(child.name=="Character"){
    10.                         buildButtons[idx].image=subChild.GetComponent<Image>();
    11.                     }
    12.                 }
    13.             }
    14.         }
    15.        
    16.         //rest of the function
    17.  
     
  41. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    12
    the tank does not come from this part, but the sign indicates that it will come from this part. How can I turn it off . In other words, if the tank will come from the a side, let it be open and the b side is closed.
     
  42. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    12
    annotation. I created 2 (PathIndicators)
     

    Attached Files:

  43. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Correct me if I'm wrong, so you want to hide the path-indicator when there's no creep coming out from that path. I'm afraid there's no simple way of doing this. You have to add your own script to do this. Basically you need a to reference all the path-indicator and their corresponding path. On every new wave, you need to scan the wave list and if a particular path has no creep assigned to it, deactivate the path-indicator.
     
  44. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    If there's no error, I can only guess that everything is working correctly and the image not showing up is due to other setting error. Is the image actually in the within the button itself? The position and size value on the RectTransform of the image doesn't look right. Have you assign the icon to the tower? Have you tried manually put a sprite on the image and see if it shows up? Have you check the button in question during runtime and see if there's any sprite has been assinged to it?
     
  45. MarvinH

    MarvinH

    Joined:
    Jul 18, 2012
    Posts:
    5
    Hello,

    I'm trying to drag a tower prefab into the prefab slot of the Tower Editor menu. Is this allowed? I can't seem to change the prefab.- Update: I figured it out!

    upload_2023-2-1_21-28-11.png
     
    Last edited: Feb 2, 2023
  46. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    12
    hello I am writing for a suggestion. making the tanks for each section gets really tiring. Does this system have copy and paste? .
     
  47. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    @darknside I spotted an error in your code. Line58. It should have been if(subChild.name=="Character"). If you want to modify a tower's damage, just use TowerEditor. It's pretty straight-forward from there.


    @MarvinH that slot is for you to verify which prefab specifically you are editing. I don't understand what exactly you are trying to do. The TowerEditor is just like the inspector but specific to tower prefab. You can add/remove tower to, or change the order of the towers. If you want to change a tower prefab in the list with another, just add that new prefab, remove the old prefab.


    @gabrifu01 Not sure what you mean by tanks for each section? Do you mean path or wave? No, I'm afraid there's no copy and paste support for this.
     
  48. toddkc

    toddkc

    Joined:
    Nov 20, 2016
    Posts:
    207
    Was this on sale recently or something? So much activity lately! :D
    Hi Song_Tan, hope you are doing well! If you are working on anything please share, I'm always interested in your projects.
     
  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm doing very well. Thanks for asking. I'm currently super busy working on my next game. Which should be announced before the end of the month if everything goes to plan.
     
    toddkc likes this.
  50. MarvinH

    MarvinH

    Joined:
    Jul 18, 2012
    Posts:
    5
    @MarvinH that slot is for you to verify which prefab specifically you are editing. I don't understand what exactly you are trying to do. The TowerEditor is just like the inspector but specific to tower prefab. You can add/remove tower to, or change the order of the towers. If you want to change a tower prefab in the list with another, just add that new prefab, remove the old prefab.

    Thanks Song Tan! I was trying to add a new tower, just playing around I figured it out. Is there an easier way to get to the item database?