Search Unity

TowerDefense ToolKit 4

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

  1. justforthesis

    justforthesis

    Joined:
    Sep 28, 2013
    Posts:
    11
    I just did that already, the reason why I'm asking this is when I load a level scene with tdtk (not saying this is causing the problem) and load the main menu problem occurs on the other hand I load a scene without it just works fine. I'm just asking, trying if you know this but if we can't solve the problem I can live with it.

    Other topic I want to attach camera in every turrets so when I clicked on them their camera is activated and a key or a button so I can go back to the main camera Any ideas? Thank you for consistently answering my calls.
     
  2. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm not sure with the level loading. It's hard to tell without looking at it. Is there any error or warning message you see in the log? If it's not too much trouble and if you dont mind. You can always send me your project so I can take a look at it.

    As for the camera, yes it can be done. But how do you want it done? Currently clicking on towers open a tower info panel, so do you want to get rid of that? Or you want to keep that while adding the camera. And where you want the exit key or button appears?
     
  3. justforthesis

    justforthesis

    Joined:
    Sep 28, 2013
    Posts:
    11
    Ok thanks forget about the loading things, When I click on the tower the camera will change but I want the panel to remain. I already tried it but I'm having errors, this is what I do I put a child camera on the barrel so the rotation of the camera will be the same as the barrel moves. I put a OnMouseDown script on the tower and it works the error is when switch to the camera in the turret the NGUI's disappear and pops up an error of "Camera.main raycast" something like that in the BuildManager script. On returning to the main camera I just want a way anything so I can switch back again to the main camera. Thanks again sir.
     
  4. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You can use something like this:

    Code (csharp):
    1.     public Camera towerCam;
    2.    
    3.     // Use this for initialization
    4.     void Start () {
    5.         towerCam.depth=Camera.main.depth+1;
    6.         towerCam.enabled=false;
    7.     }
    8.    
    9.     // Update is called once per frame
    10.     void Update () {
    11.         //press spacebar to exit the camera
    12.         if(Input.GetKeyDown(KeyCode.Space)){
    13.             if(towerCam.enabled) towerCam.enabled=false;
    14.         }
    15.     }
    16.    
    17.     void OnMouseDown(){
    18.         if(!towerCam.enabled) towerCam.enabled=true;
    19.     }
    20.    
    21.     void OnGUI(){
    22.         if(towerCam.enabled){
    23.             if(GUI.Button(new Rect(Screen.width/2, Screen.height/2, 50, 50), "X")){
    24.                 towerCam.enabled=false;
    25.             }
    26.         }
    27.     }
    Put it on the tower object and be sure to assign the camera for the tower as TowerCam. Also make sure the depth of the main camera is lower then the towerCam and the depth of the camera of the NGUI camera is higher than the towerCam.
     
  5. justforthesis

    justforthesis

    Joined:
    Sep 28, 2013
    Posts:
    11
    Thanks song, is 50, 50 the position of the GUI "X" ?. I very much appreciate your help :D.
     
  6. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    The whole new Rect(Screen.width/2, Screen.height/2, 50, 50) is the position of the button, the first 2 parameters being the starting x and y position, the last 2 being the width and height of the button. You can try change the value and see what happen.
     
  7. justforthesis

    justforthesis

    Joined:
    Sep 28, 2013
    Posts:
    11
    Song, Pardon me for asking too much questions you know I'm just new to unity. In my game, my creeps is cars they come with different speeds as some point in time they collide with each other but they are glitching/overlapping with each other is there something that can solve this one a rigidbody or box collider I guess. And does your plug-in have score?
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    No problem at all. We all were beginner at some point. I'm afraid there's no way to avoid the mesh overlapping each other. While you can use rigidbody and collider to force the creep into not overlapping each other, but doing so may break the creep waypoint based navigation system so I wouldnt recommend it. The only way to make this overlapping issue less obvious is to use dynamic waypoint on the path component itself, set it to a higher value so that the creep spread out over both side of the path instead of bump together right in the middle.

    Yes, score calculcation are supported (refer to the endless example). Just put a ScoreManager into the scene and that's it.
     
  9. justforthesis

    justforthesis

    Joined:
    Sep 28, 2013
    Posts:
    11
    I can't locate where the ScoreManager is on the tdtk menu I only have audio manager, cameratocontrol, perkmanager, overlay manager and editors. Where can I find that? I also search among my project files.
     
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Sounds like you are not using the latest version. The latest is 2.2.4
     
  11. justforthesis

    justforthesis

    Joined:
    Sep 28, 2013
    Posts:
    11
    Song, I think with the loading level issue the problem comes from the Pause menu does your code disables all functions when your on pause menu? If so this might be the issue, when I clicked the pause and clicked the main menu button the pause function comes along through the main menu that's why the fire particles stop working and the buttons also are not functioning in the main menu. Another scenario is when I activated the x3 button and until I finished the game and load it through the next scene the x3 function also comes along. Do you know how to fix this?
     
  12. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There used to be a bug with older version of TDTK, where the timeScale doesnt reset properly from the the pause function or fast-forward function when loading a new level. But I'm pretty sure I've fix that. An easy way to get rid of the problem would be add Time.timeScale=1; in the start of your own scene.
     
  13. WhiteCastle

    WhiteCastle

    Joined:
    Sep 6, 2013
    Posts:
    14
    Thanks, worked great. Now I wondering how to disable the popups when hovering over a new perk. (The one that shows its name and cost?)
     
  14. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I'm afraid you will have to be more specific. First I dont think perk item has a pop up tooltip. Are you refering to build button or ability button? Or are you refering to the tooltips in editor?
     
  15. WhiteCastle

    WhiteCastle

    Joined:
    Sep 6, 2013
    Posts:
    14
    When you are choosing a tower from the builder. When you hover over a tower is shows a popup. Thanks. $a.png
     
  16. WhiteCastle

    WhiteCastle

    Joined:
    Sep 6, 2013
    Posts:
    14
    I wound up commenting out the ShowToolTip(ID); line in OnGui in the UI.cs script. Not sure if there is a better way. Thanks.
     
  17. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I was just about to suggest that. Disable the the tooltip function call would the easiest way.
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Just a quick note that I'll be travelling for a week starting now. Apologize in advance for the delay in responding to any post.
     
  19. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    Just a quick question. Is there any way to make it so that you can fully block off a certain path from enemies so that they have to go a different to a different path to get to the next platform?

    An example would be like in the game Sanctum, you can fully block off a pathway so that you can funnel the enemies into one pathway instead of having them go through all 3 paths. This will obviously be restricting you from FULLY blocking the enemies in on the last pathway.

    Thanks in advance.
     
  20. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You can certain do that. But there are certain limitation. That is you can only do so within a platform. From platform to platform, each path have to follow certain a waypoint. Only within a platform, the path can be altered based on the obtacle. So the player can place the obstacle to funnel the creeps into 1 specific path like you said. And yes, the player cant block all possible path. There is a check to make sure other possible path still exist before any tower/obstacle is placed.
     
  21. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Unfortunately there's no way to do that now, not without heavily modifying the code anyway. Any easy way would be to change the unit rotate speed so that the mesh turn more slowly, creating the illusion of a smoother turn. But that wont change the movement direction at all, which will still result in a sharp change of direction.

    I can try to see if I can do anything to remedy that when I have time in the future. But frankly it wont be easy to modify the current existing code and still keep it as efficient as it's now (at least on mobile) so I wouldnt hold my breath.
     
  22. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    Thanks for the reply on my last post!

    Another question, is there any way to make complex camera boundaries so that my camera doesnt clip through buildings using rotate.

    My scene is similar to Anomaly: Warzone so there are tall buildings all over. thanks in advance. I do recall something about this in your video tuts but cant seem to find it.
     
  23. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    There's no way to define complex camera boundaries. But I've just add in the code to avoid clipping and pm the new addition to you. Please try that out.
     
  24. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    Ok so i checked the box. So in the scene i have on a prefab a mesh collider set at NOT TRIGGER with no tag and on a Default layer. The camera still goes through the bulding.

    Is there anything im doing wrong
     
  25. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Turns out there's a bug I left in. Try remove line314 in CameraControl.cs. Note that it will work against any collider. So make sure you place the camera parent object a bit higher from the build platform so it wont clip with the tower or terrain collider.
     
  26. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    Hmmm, even with that edited i am still able to move the cam through the buldings.
    $camclip.PNG
     
    Last edited: Oct 11, 2013
  27. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Ok, I think the problem is your camera pivot point is in the collider itself to start with. The code is intended to work like a 3rd person style camera clipping prevention. It assume you are not using a top down view. So I'm afraid it wont work in your case. What you can do is add a small rigidbody collider (with gravity off) right at the pivot transform, so when you move the camera around, it wont move into a collider object.

    *if you are using the default camera setup, the pivot transform is the gameObject which CameraControl is attached to.
     
  28. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    That did the trick, thank you. Just had to also freeze the constrains for rot also in the RB.

    Thanks.

    having fun with a framework for once, very easy/sophisticated TD kit
     
  29. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    Tried to make a turret, get this error? Also, turret does nothing once placed in-game.

    Any idea whats goin on?
     
  30. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I've check the script. It seems that your code is not matched to the one I have. Can you sent me your UnitTower.cs so I can see which is the line that cause thge problem. Judging from the error, probably you havent assign some dependencies properly.
     
  31. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    i can possibly be that my asset store hasnt been working and i see that i am behind a update?

    Is there anyway to get the latest update because i cannot open the asset store.


    Heres the UnitTower cs
    http://pastebin.com/dYdYqifi
     
  32. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    From what I can tell, the error occur because you assign a prefab without a shootObject.cs component to the tower as ShootObject. Make sure the shootObject you use has ShootObject.cs attached to it.

    If you want to update to the latest version, please send me an email.
     
  33. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    Ok that was the issue, thank you. The creeps arent dying however. In the process of constructing my own instead of the default ones so i will edit the post if i have an issue with the creeps. thank you
     
  34. thomas4d

    thomas4d

    Joined:
    Sep 5, 2013
    Posts:
    56
    where is the information on replacing prefab ? the template content is a single object in a stack,. there is no information in the PDF and if I search this forum ( how to replace prefab ) all I get is nice post titles BUT the link only sends me to the first page of a 42 page thread ?? ( can the unity search be that bad ? ) can any give me a simple run down on the template objects and how to replace them ?? or a link ?

    You tube video's are private WHY ?? where how do i find the "special link" so i can watch the document I paid for when i purchased these tools ?

    is there a FAQ some where for these Templates ?

    Thanks
     
    Last edited: Oct 15, 2013
  35. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    From the email you sent me, I understand you made the purchase a year ago. Have you got the latest version from the AssetStore? I've done quite a lot of update and changes since then. If you are still using the old copy and looking at the old PDF, the link to the video might have obsolete.

    Try update your copy and and go through these videos. I have to say even some the stuff in the videos are a bit out of date. But it should give you some pretty good idea how to do most of the stuff.

    Now to your specific question. What are you refering to as the template content? And in what way you want to replace them? Are you refering to the towers and creep prefab and you want to replace the mesh?
     
  36. thomas4d

    thomas4d

    Joined:
    Sep 5, 2013
    Posts:
    56
    I got the latest but your video seem to be for a older version ?

    OK I have new mesh data how do i get that into the game ?
    I see the main object has ALL the tower in the same object ( different layer )
    then you have a scene with just towers called Example scene with different towers setup
    What is this exsample scene used for ?

    and then when i go to the Tower Manger menu you have a base and tower item button cool BUT it does not show any object i have brought into the game ? just towers you have in the template ? how do i bring item into the Tower menu ?
    thanks

    $prefab help.jpg
     
    Last edited: Oct 15, 2013
  37. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Some of the features shown in the video might be a bit out-dated but on the core, things still works the same. Especially about setting up a prefab, using custom mesh and what not. The Example Scene is just there to show how different type of towers can be setup using the mesh. If you lookat the video about Towers, you will notice how I can duplicate gameObject, rearrange them however I like. So that is what you can do. Just drag your Base_001 into Hierarchy and you will see you can separate different mesh into different gameObject and build a variety of twers from there. That is unless you havent separate the mesh. Either way you can drag the ModularTowerSet into the scene and you will see what I mean.

    As for how to get your object to show up in the eidtor. Just follow the steps in the video. The only thing changed from the video is the interface where you assign the TurretObject, BaseObject, etc.
     
  38. thomas4d

    thomas4d

    Joined:
    Sep 5, 2013
    Posts:
    56
    dude your current update IS ALOT different to your Video's
    PLUS you video Jumps around the information so Much from shoot position to Base or Turret to prefab ??
    information is everywhere Nothing is focus it very hard to follow what is need or find what i need to know 17 min most of it is talking about pivot and shoot position ??

    I still shocked to see the MAIN THING I need to know.. well you do that OFF SCREEN on the video ??? WTF ?
    come one dude help me here ? what am i missing ? give me the steps to get a item into YOUR TOWER TEMPLATE please !! the Whole 12 min mark of the video is where the information I need IS BUT
    1/ the new version does NOT let you drop in models like ( I GUESS is what is happening off screen)

    2/ there NO information on what has changed in the new version SINCE the base and tower items and now internal or NOT directly drag and drop or selectable in the unity interface



    do I assign a script to the object BEFORE i make a prefab ? SO you tower manager see my prefab ?

    if so what script do I add ? you have 3 I can see I have tried but no having any luck ( in the video it show unit)
    but in my current version I have "Base object" "Tower Object" and "Tower"

    I just want to replace the base right now and would like some clear information on how to do it ?

    and PLEASE I an NOT a unity newbie I want information related to working with THIS template.
     
    Last edited: Oct 15, 2013
  39. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Tthis is the precise steps you need to follow:
    • create an empty gameObject,
    • drag your mesh into the gameObject
    • attached the script UnitTower.cs to the your gameObject
    • make the gameObject a prefab by dragging it into ProjectTab.
    • drag the prefab to TowerManager, into a slot on top of the TowerManager window which has label "Add new tower:" (I believe this is the only bit I'm doing off screen because if I keep the window in the same area of UnityEditor, as soon as I click on the prefab to drag it, the TowerManager window will be put off screen behind UnityEditor, where I wont be access it.) You cant do this step until you have a prefab which have a UnitTower attached to it.
    • now the tower should be in accessible in TowerEditor now.
    So you want to replace the base of a prefab, you can modify the prefab hierarchy in theSsceneView. Just take out the gameObject that contain the mesh of the base, and place one that have the new mesh that you want. Make sure you apply the change to the prefab after you have done.

    I could make a video showing you precisely what need to be done that but I'm not sure how helpful that will be given that I'll be mostly doing things that have already been shown in the current video. Anyway, let me know that and give me sometime and I'll get to it.

    I spend a good deal of time taking about pivot point for good reason. You will find that making a prefab is the easy bit compare to getting the tower operate, aim properly and shoot from the right place.

    Finally please chill, I understand your fustration. But shouting usually dont help.
     
  40. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    If you are not a "unity newbie" you would know what he is doing, its pretty self explanatory if you follow the videos not pissed off....



    Anyways, i do have an issue of my own. I think that fix we did for my camera may have broken it in hindsight. Here's the error code:
    Code (csharp):
    1. NullReferenceException
    2. UnityEngine.Camera.ScreenPointToRay (Vector3 position) (at C:/BuildAgent/work/7535de4ca26c26ac/Runtime/ExportGenerated/Editor/UnityEngineCamera.cs:376)
    3. BuildManager.SetIndicator (Vector3 pointer) (at Assets/TDTK/Scripts/C#/BuildManager.cs:498)
    4. UI.Update () (at Assets/TDTK/Scripts/C#/UI/UI.cs:272)
    Now this is the message i get when i activate other static cameras in my game (security cameras).

    After like 1 min of game-play, the main camera goes flying off the screen glitching. Could this be because i am using other cameras?
     
  41. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I suppose when you switch to other camera you deactivating the main camera? The problem is when you do that, the main camera is no longer is used and the code cant find it. Instead of disable the main camera, you can play with the camera depth setting so that the "security camera" view port will be displayed on top of the main camera. This way you dont need to disable the main camera. But I suppose it's kind of my fault for some lazy coding. I'll try to fix it in my code. I'll send you the fix when it's done.

    As for the camera flying off screen. It's hard to say without seeing it. In what way it flys off screen? The camera transform itself goes berserk? If so it could be because of the rigidbody collider you add to it. Try move the camera into a position where it's collider free and leave it be, see if the problem still persist. If the camera transform is not the issue, please give me a screen shot. I'll see if I can figure out what's wrong.
     
  42. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    This is the script for the cams.
    http://pastebin.com/nHdeUXBw

    This happens basically wherever, its just random. Sometimes it happens when im hovering over a platform spot. But that error code comes from when i switch cameras not on the initial startup.
    The main camera is set as top down without rotation. So it moves in the y axis straight up endlessly when this glitch happens. So possibly it is the rigidbody.

    Ill see if i can get it on video.
     
    Last edited: Oct 15, 2013
  43. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    I've just pm you a small fix. That would get rid of the error when you switch camera.

    Now you mention that the camera only move straight up. It could be due to the new anti-clipping code. I havent manage to replicate that but there's certainly a possibility. Try disable avoid clipping flag to make sure. If possible, send me a screen-shot of your camera rigidbody setup. And most important thing is, let me know if it's the camera rootObject or the camera transform itself that is moving.
     
  44. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    Last edited: Oct 15, 2013
  45. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Right, here's the thing. There's "Camera" (root-object, as pivot point) and "Main Camera" (actual camera object). When the glitch happen, let me know why object is moving. If you disable maximise on play, you should be able to read the position value of both the gameObject in the inspector. Please let me know that.

    There are two possibilities why this could happen. First is the physics interaction of rigidbody, second is the bug in the code. I would suggest you to try set Drag and AngularDrag on rigidbody to a relatively high value, like 100 or so. So that it wont slide around. Also if it has no bearing on the controlled movement, try freeze position constraint on y-axis. If this two doesnt fix the problem, try remove rigidbody and give it a go. If the problem doesnt happen when rigidbody is gone, then at least we eliminate the possibilty of a bug in the code.

    I'll be off for the night. Please let me know what you find out, I'll try to figure things tomorrow. Hope you understand.
     
  46. GLucasDev2

    GLucasDev2

    Joined:
    Jul 24, 2013
    Posts:
    77
    So removing the rigidbody seems to have fixed it, but now the same problem as before is at hand. The camera can go through the colliders and inside buildings.
     
  47. thomas4d

    thomas4d

    Joined:
    Sep 5, 2013
    Posts:
    56
    First I do apologize if you took my post as yelling (tho all CAPITALS is yelling in internet land )
    I used CAPITALS to show the words I need extra focus on I spent afew hours going in cycles then i was think it should not be this way documentation is important to any release and i couldn't find any on a very basic issues when you buy template projects ,. how to replace the template content

    Second THANK YOU that is the information I needed, I am very grateful for your work on these templates AND your replies and support you very active here in there thread it's a pity these unity forum can not be search and reference alittle better.
     
  48. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    Modifying the drag value and enable y-axis movement constraint doesnt help?


    Indeed, unfortunately unity forum is the only medium we have without resorting to any 3rd party solution. I apologize for mis-interpreting your tone in your post. I admit documentation is not the strongest point of the framework. This is due to the rapid development/update spree that I have done over a certain period to full fill request and fixed cirtical issues. As a result the ducomentation end of stuff cant keep up. I'm looking forward to remedy that sometime in the near future.
     
  49. thomas4d

    thomas4d

    Joined:
    Sep 5, 2013
    Posts:
    56
    Unfortunate I am still having issues
    I know it's something simple I'M DOING ! =) so would like any help to find the missing piece of the method I'm not doing

     
  50. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,993
    You are doing everything right, but you seems to have ran into a bug I thought I've fixed. Probably I still havent uploaded it to AssetStore. Anyway, I've email you the fix. Please check your email.