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.

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,889
    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,889
    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,889
    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,889
    I'm pretty sure I've sent you a package containing the fix. Check your inbox.
     
  10. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    295
    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,889
    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:
    295
    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,889
    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:
    295

    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,889
    Just deactivate PerkManager and AbilityManager in the scene.
     
  16. darknside

    darknside

    Joined:
    May 4, 2021
    Posts:
    19
    Can it be used in 2D games?
    I created a prefab from a 2d sprite and for some reason it turns and is poorly displayed to me
     
  17. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
     
  18. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    11
    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?
     
  19. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
     
  20. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    11
    My camera moves without limits. a certain movement limit on mobile what should i do
     
  21. darknside

    darknside

    Joined:
    May 4, 2021
    Posts:
    19
    Could you throw a fix for 2d games here?
     
  22. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
  23. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    11
  24. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
  25. gabrifu01

    gabrifu01

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

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
  27. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    11
    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
  28. darknside

    darknside

    Joined:
    May 4, 2021
    Posts:
    19



    unfortunately, it does not work out to solve some errors with one jackdaw.
     
  29. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
     
  30. darknside

    darknside

    Joined:
    May 4, 2021
    Posts:
    19


    As you can see, there is a problem with the Pivot, as well as the construction platform turns 90 degrees at the start of the game
     
  31. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
     
  32. darknside

    darknside

    Joined:
    May 4, 2021
    Posts:
    19
    it's the same with your prefabs
     
  33. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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
     
  34. darknside

    darknside

    Joined:
    May 4, 2021
    Posts:
    19

     
  35. Song_Tan

    Song_Tan

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

    upload_2023-1-24_17-33-14.png
     
  36. darknside

    darknside

    Joined:
    May 4, 2021
    Posts:
    19
    So after all, I have a 2d game like a regular TD
     
    Last edited: Jan 28, 2023
  37. darknside

    darknside

    Joined:
    May 4, 2021
    Posts:
    19
    Can you tell me how to solve this problem and where to look?

    upload_2023-1-29_0-9-50.png


    NullReferenceException: Object reference not set to an instance of an object
    AssetsPack.TDTK.Scripts.UI.UIHUD.Start () (at Assets/AssetsPack/TDTK/Scripts/UI/UIHUD.cs:60)
     
  38. darknside

    darknside

    Joined:
    May 4, 2021
    Posts:
    19
    upload_2023-1-29_0-21-17.png upload_2023-1-29_0-21-38.png

    I just replaced Text with Text_meshpro


    [HideInInspector] public TMP_Text label;
     
  39. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
     
  40. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    11
    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. }
     
  41. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
     
  42. gabrifu01

    gabrifu01

    Joined:
    Jan 16, 2023
    Posts:
    11
    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 ) :)
     
  43. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
     
  44. darknside

    darknside

    Joined:
    May 4, 2021
    Posts:
    19
    upload_2023-1-30_2-4-57.png

    How is the firing radius to be done in 2d?
     
  45. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
     
  46. darknside

    darknside

    Joined:
    May 4, 2021
    Posts:
    19
    upload_2023-1-31_1-3-29.png upload_2023-1-31_1-3-57.png upload_2023-1-31_1-4-9.png

    What could be the matter that he can't find?
    Also, why is the canvas of groups 0 on the object from the start of the game, because of this, it does not display the construction button
     
  47. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    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.
     
  48. gabrifu01

    gabrifu01

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

    darknside

    Joined:
    May 4, 2021
    Posts:
    19
    You misunderstood, you have the icon of the tower passes here

    upload_2023-1-31_13-46-20.png

    And I need to get here

    upload_2023-1-31_13-46-52.png

    I understand this code is responsible for this?how can I change it so that it works as I need?

    upload_2023-1-31_13-48-57.png
     
  50. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,889
    @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.