Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

3D Tower Defense Starter Kit

Discussion in 'Assets and Asset Store' started by Baroni, Mar 30, 2012.

  1. Hardik

    Hardik

    Joined:
    May 26, 2013
    Posts:
    7
    One more query after rebaking there is not light effect in scene And also i am changed the directional light intensity to max value (i.e. 8).you have any idea about that?
     
  2. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    What do you mean with "there is no light effect in the scene"? If set to RealtimeOnly, the light will affect every object on its culling mask, which should be set to e.g. enemies, projectiles and towers. Page 8 in the documentation also has an image for the culling mask and a brief description on how to set up the light (first to BakedOnly to bake the lightmap, then to RealtimeOnly).
     
  3. Andreas12345

    Andreas12345

    Joined:
    Oct 17, 2013
    Posts:
    526
    When i import the package it crashed unity. Importing small Assets then crash :(
     
  4. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    You need to use Unity 4.6.

     
  5. Andreas12345

    Andreas12345

    Joined:
    Oct 17, 2013
    Posts:
    526
    ieks. My Fault
    Thx for the answer Baroni! FTL
     
  6. Andreas12345

    Andreas12345

    Joined:
    Oct 17, 2013
    Posts:
    526
    Ok, i have loaded 4.6. but what we do here?:
    Assets/3D Tower Defense Starter Kit/Examples/Advanced/Scripts/Adv_GUIImpl.cs(92,13): error CS0103: The name `EventSystemManager' does not exist in the current context
     
  7. Andreas12345

    Andreas12345

    Joined:
    Oct 17, 2013
    Posts:
    526
    Code (CSharp):
    1. -----CompilerOutput:-stdout--exitcode: 1--compilationhadfailure: True--outfile: Temp/Assembly-CSharp.dll
    2.  
    3. Compilation failed: 1 error(s), 0 warnings
    4.  
    5. -----CompilerOutput:-stderr----------
    6.  
    7. Assets/3D Tower Defense Starter Kit/Examples/Advanced/Scripts/Adv_GUIImpl.cs(93,12): error CS0103: The name `EventSystemManager' does not exist in the current context
    8.  
    9. -----EndCompilerOutput---------------
    10.  
    11. - Finished compile Library/ScriptAssemblies/Assembly-CSharp.dll
    12. Assets/3D Tower Defense Starter Kit/Examples/Advanced/Scripts/Adv_GUIImpl.cs(93,12): error CS0103: The name `EventSystemManager' does not exist in the current context
    13. (Filename: Assets/3D Tower Defense Starter Kit/Examples/Advanced/Scripts/Adv_GUIImpl.cs Line: 93)
     
  8. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Thanks for noticing this. It seems that one of the newer beta versions changed how EventSystems are being handled (the current version was submitted with beta 17):

    Just replace all calls to EventSystemManager.currentSystem.IsPointerOverEventSystemObject() with EventSystem.current.IsPointerOverGameObject(). I will release a hotfix for this in the coming hours.

    Edit: Version 1.7 for beta 20 is now online.
     
    Last edited: Oct 4, 2014
  9. Andreas12345

    Andreas12345

    Joined:
    Oct 17, 2013
    Posts:
    526
    Works. Thx Baroni
     
    Baroni likes this.
  10. drothrock

    drothrock

    Joined:
    Sep 6, 2014
    Posts:
    6
    Hello, just purchased your 3d tower defense. Struggling to import it to check things out, though. Getting this error:

    Assets/3D Tower Defense Starter Kit/Examples/Advanced/Scripts/Adv_GUIImpl.cs(92,25): error CS0117: `UnityEngine.EventSystems.EventSystem' does not contain a definition for `current'




    Any idea what I'm doing wrong?
     
  11. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi drothrock,

    the current version is meant for use with Unity 4.6 beta 20, there have been some minor changes in the last betas. Please try reimporting this kit in beta 20 (link).
     
  12. drothrock

    drothrock

    Joined:
    Sep 6, 2014
    Posts:
    6
    Oh okay, thank you so much for the quick response. I will try it out now.

    Everything in the kit looks great, by the way. I'm very excited to get started and then someday adding my game to your list of good tower defense games that use your model!

    Haha, cheers!
     
  13. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    You're welcome :) Let me know when you've published your game and I'll add it to our showcase section.

    Good luck!
     
  14. Andreas12345

    Andreas12345

    Joined:
    Oct 17, 2013
    Posts:
    526
    WoW, you can do a complete level in less then 2 hours. *impresssive* :)
     

    Attached Files:

    Baroni likes this.
  15. eliteslayer

    eliteslayer

    Joined:
    May 12, 2013
    Posts:
    64
    II would love to buy this asset but 65 dollars is way to much for the kind of limited budget, will there be any price reduction soon? Thank you looks great.
     
  16. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
  17. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Version 1.7f
    Bugfixes and workarounds for the final uGUI release:

    - fixed mobile touch behavior registering input on towers & powerups
    - fixed powerup target/area selection when playing on mobile devices
    - fixed powerup countdown timer not showing up

    This will be the last release in the 1.x cycle.
     
  18. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    Hello everyone, little noob question, i made up the background for the Menu scene and i'm now trying to change the pic on the canvas but I'm not finding where I can change the shader. Let's say I change the Source Image in the Component Image (Script) from the GameObject Image - Title ; where do I change the shader for the pic I just added.
    must be pretty simple but I just spend 2 hours on it.

    thank you
     
  19. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi Dami, each image component has a material slot. Shaders are assigned to a material, so create your material with the desired shader and assign it to the image component afterwards.
     
    MyOwnGames likes this.
  20. LandonC

    LandonC

    Joined:
    Dec 20, 2012
    Posts:
    83
    Hello there, I have to say I love the powerup update! but currently I'm facing an issue trying to make my own "powerup" skill to kill the enemies. First thing, I'm not very good at understanding how the enemy health works so basically I've come up with OnTriggerEnter script to try to decrease the health of the enemies, but it didn't workout as I don't really know how to call the Properties component of the enemy clones from my other script.

    Using another method which I am okay with is to directly destroy the gameobject the "powerup" collider collides with, it works, the enemies get destroyed, but the thing is the towers that are attacking the enemy would come out with an error and they wouldn't attack enemies after that.

    the error as follows:
    MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.

    So.. my question is, if possible can you guide me to know what I should do to decrease the health without using the Powerup Script in the template? or can you tell me what I do I need to add to allow the towers to go back to an idle state when the enemy gameobject is null after it is destroyed?
     
  21. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi Landon,
    powerups automatically decrease hit points of enemies if you entered a damage value in the PowerUp Settings editor (see the "Skyfall" powerup dealing 15 area damage). There's not much point in doing this manually, which could lead to unexpected behaviors; but if you want to do that you can call PoolManager.Props["name of your enemy clone"].Hit(damage value).

    Edit: Are you sure you posted your question in the correct thread? I just saw the exact same question elsewhere.
     
  22. LandonC

    LandonC

    Joined:
    Dec 20, 2012
    Posts:
    83
    Thanks for the prompt reply! I will try that out, by the way, is there anyway I could make the towers go back to their initial state if the gameobjects are destroyed without the health points going down to zero? Like for instance checking if the gameobject is null or something. Because this would be a quicker way for me.

    Yeah I did posted on another thread, not sure where to post, sorry for the confusion.
     
  23. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Do you mean the tower turret should rotate to their original positon? Turret's will stop rotating if there aren't any enemies in range, otherwise they will follow them. For a "customized rotation" implementation, CheckRange() in TowerBase.cs would be the best spot, which gets called in an interval defined by the tower shot delay. Make sure to disable the rotation script on your turret before doing this manually though.
     
  24. LandonC

    LandonC

    Joined:
    Dec 20, 2012
    Posts:
    83
    The tower does not have a turret, but basically it just stops shooting at enemies after the error occurred. I was fiddling with currentTarget and inRange[0].transform to become null but it does not work, then I went to tried on CheckRange but its not working either.

    The PoolManager.Props["name of your enemy clone"].Hit(damage value) did worked but it only works with the particular enemy clone name, not the original prefab name, which is not useful, it needs to be applied on all of the clones.
     
  25. LandonC

    LandonC

    Joined:
    Dec 20, 2012
    Posts:
    83
    Hey I got the script to work! Thank you so much for your guidance!

    This is what I did

    if(other.gameObject.tag == "Ground")
    {
    other.gameObject.GetComponent<Properties>().Hit(damage amount);
    }
     
    Baroni likes this.
  26. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Even simpler (performance-wise):
    Code (csharp):
    1. if(other.gameObject.tag == "Ground")
    2. {
    3.     PoolManager.Props[other.gameObject.name].Hit(damage amount);
    4. }
     
  27. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    Hello everyone,

    first of all thank you Baroni for your last answer,
    I'm coming with a other problem, since I spent hours on it.

    Here it is, I set up my tower but :
    (1) my tower deals damages normally at enemies but don't turn to face enemies (the script TowerRotation doesn't seems to be working when attached directly to the tower)

    (2) if I put my tower into its own turret field, it now turns correctly but does not shoot at enemies anymore.

    I tried to do exactly as you said (follow the same model as BallistaTower and put into 'Turret' only the part which is turning) but when I turn my asset into a prefab using the Tower Setup Windows it only gives me one prefab and not the differents parts of it.

    If you have any idea...
    Thank you

    edit : ha, and since I'm here, I can't play my animations for my tower through the Idle Anim and Shot Anim in the Tower Base script of the prefab, it doesn't work. But my animations seem corrects and can be played on the asset with the Animator Component.
    It tells me "there is no Animation attached to the Game Object, but a script is trying to access it. You probably need to add a animation to the game object, or your script needs to check if the component is attached before using it." but I definitly added the animations in the Idle and Shot Anim fields, did it as protoTower1 and did not change the BaseTower script
     
    Last edited: Dec 20, 2014
  28. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi Dami,

    Towers with turrents need to be separated into different objects in your modelling application, meaning the turret is a child object of your turret object. This makes sure that both parts can be rotated independently (like the CannonTower or BallistaTower). In Unity, the TowerRotation script then goes just on the turret gameobject. Lastly, on the TowerBase script you have to assign the turret gameobject to the corresponding slot.

    See (1).

    Unity can only display one additional level on prefabs in the project panel. If you drag the prefab into your scene, you will be able to see its full hierarchy and all child gameobjects on it.

    Hope this helps, B.
     
  29. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    Ok, I'll try to do as you said and then come back here,

    edit : so, I did what you said but when I put my turret in the 'turret' field, each time I click on a new free grid case during the game it deletes the previous tower I built

    sorry, I'm editing this post so much to say so few things...
     
    Last edited: Dec 20, 2014
  30. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Animations using Mecanim are not supported in the current version of the kit, you will have to use legacy for now. If you're running into further issues with your tower prefabs, you can also send me your model+prefab and I'll set it up for you + provide a bullet list of things that I've corrected.
     
    MyOwnGames likes this.
  31. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    ok great, I'll see what can I can try to do for now and send ou a new message if I don't come up with a solution,

    thank you for your really helpfull support.
     
  32. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    Good afternoon Baroni!

    sorry but I didn't end up with a solution, it's still the same problem after I try with a other model, if I put my turning part into the 'turret' field my tower turns but doesn't shoot, while all is almost good when I play it without turret.

    Almost because I still can't play my animation even after I did it with the animation editor from Unity:(
    if you have any idea or if I can send you a piece of my work to look at it

    thank you
    Damian

    edit : of course I didn't use any rig or skeleton part to play my anim
    edit again : do I have to re-make the animation with my prefab or does it work with the asset animation?
     
    Last edited: Dec 22, 2014
  33. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    @dami
    Did you set the shotAngle variable on the TowerBase script to something greater than 0?
    You can always send me prefabs+models or projects to info [at] rebound-games [dot] com and I'll take a look.
     
  34. djacobson

    djacobson

    Joined:
    Jul 15, 2014
    Posts:
    6
    Hi. Every time i try to import the assets into Unity3D pro. It gets up to Importing Small Assets and than freezes and crashes unity3d. Can you please help. Thanks
     
  35. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Already answered 4 months ago:
    http://www.rebound-games.com/forum/index.php?topic=95.0
     
  36. fearfactory

    fearfactory

    Joined:
    Jun 11, 2013
    Posts:
    49
  37. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Performance usually isn't a bottleneck in starter kits. It depends on your models, draw calls and device limitations.
     
    fearfactory likes this.
  38. fearfactory

    fearfactory

    Joined:
    Jun 11, 2013
    Posts:
    49
    Very fair answer!

    And what do you feel sets your asset package apart from it?
     
  39. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Both kits are very similar feature-wise, but I think the tower self-control functionality with mobile controls is one of the key points in our kit. Pathfinding and games like Plants vs. Zombies will be possible in the next update (for Unity 5).
     
  40. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    Hello Everyone & Baroni!

    I rewrite my question :

    Ho do I use the removeTower function from the properties script?
    I passed the TowerBase to destroy as a argument but nothing happened...
    RemoveTower (nearTowers [towerToKill]);

    thank you

    edit : Ok, think RemoveTower is just to remove the tower from the nearTowers list...
    so coming back to my first question : what function may I use to remove a Tower from the code?
    I did not find any in TowerBase.cs or TowerManager.cs...
     
    Last edited: Jan 14, 2015
  41. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hi Dami,
    you can use a modified method used for selling a tower, have a look at SellTower() in GUIImpl.cs. It calls GUILogic.SellTower(), which frees the grid and makes it available for another tower. Also GUIImpl.SellTower() destroys the tower via DisableMenus() -> CancelSelection(), but what you only need is Destroy(your tower gameobject).
     
  42. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    Sorry I edited my question without refreshing the page and didn't see your answer!

    thank you very much, i'll try this!
     
  43. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    EDIT : SOLVED IT writing a new method, thank you for your indications

    Hello again! So I tried to do what you said but I really don't get how to select the tower I want to destroy.

    in my properties.cs I have something like this :

    And I get this message in my console :

    I do think it's because GUIImpl is attached to many gameobjects, but if it's the case I don't know how to specify the tower I wanna destroy
     
    Last edited: Jan 14, 2015
    Baroni likes this.
  44. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    ho... In fact it was a short false joy, I still have the same problem with the new function... :(

    If I do :
    nearTowers [towerToKill].GameObject.GetComponent <GUIImpl> ().SellTower();
    or
    GameObject.Find("GUI").GetComponent<GUIImpl>().SellTower();
    or even with an overloaded SellTower (GameObject tower) where I directly pass the tower as an argument it does not work correctly.

    A tower is sold but not the good one. It is always the last tower I created which is sold. For example if I create 2 towers on the way of my enemy, the enemy stops next from the first tower, but it'll destroy the 2nd tower (even if the 2nd tower is too far to interact with the enemy)

    So sorry to bother you again, but I really don't get how to pass the tower I want to destroy once I find it using the nearTowers list

    thank you
     
  45. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Hey Dami, maybe I don't get what you are trying to do, but there shouldn't be a reason to remove a tower from the nearTowers list manually. Towers are removed automatically from this list when they are deactivated or destroyed.

    Could you explain what's your concept behind this? SellTower() won't work, simply because it sells the selected tower (the last one you've placed). I meant that you can create an additional method based on SellTower(), not just call it directly. This is all code you need:

    Code (csharp):
    1. void DestroyTower(GameObject tower)
    2. {
    3.         //---- copied from SellTower() in GUILogic.cs ----
    4.         //define ray with down direction to get the grid beneath
    5.         Ray ray = new Ray(tower.transform.position + new Vector3(0, 0.5f, 0), -transform.up);
    6.         RaycastHit hit;
    7.  
    8.         //free grid the tower is standing on
    9.         //raycast downwards of the tower against our grid mask to get the grid
    10.         if (Physics.Raycast(ray, out hit, 20, SV.gridMask))
    11.         {
    12.             //get a reference to the Grid Manager
    13.             GridManager gridScript = GameObject.Find("Grid Manager").GetComponent<GridManager>();
    14.             Transform grid = hit.transform;
    15.             //remove grid from the "occupied"-list
    16.             gridScript.GridList.Remove(grid.name);
    17.             //change grid material to indicate it is free again
    18.             grid.renderer.material = gridScript.gridFreeMat;
    19.         }
    20.  
    21.         //destroy the tower
    22.         Destroy(tower);
    23. }
     
    MyOwnGames likes this.
  46. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    Ok! great! I didn't wanted to remove the tower from the nearTowers list but just pick the tower in this very list and send it to the SellTower method so as to it destroy it. But thank to you your code's doing the job very well. :D:D:D
     
  47. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    Hello everyone and Baroni! Thank you again for last week!

    Sorry to bother you again, I feel like I'm the only one posting here...

    I have few questions regarding the Self Control Part of the asset,

    First, I cannot move the camera where I want while I'm selecting a tower, if I change towerHeight in the con class of the GUIImpl script, it doesn't do anything when selecting the tower ; and if I change towerHeight while calling the initialize() metod from GUIImpl, or directly in the SelfControl script, the camera goes where I want but immediatly goes back to a wrong position (whatever the value I put into towerHeigh (-30000, +100000...) the camera always goes back to the top of the tower, but higher or lower, as there are min/max limits)

    My second question was about the crosshair, I have the Crosshair GameObject at first level of my Hierarchy window when starting the game but I can't see any when controlling a tower, when I move the joystick my tower do not turn, do I have to re-activate it somewhere? It works well with the original asset but I can't remember when it stops to work properly
    -> Edit : I succeed to make the crosshair come back, it was because I hadn't set the Layer of my Terrain to WorldLimit. still working on the camera move

    If you have any idea
     
    Last edited: Jan 20, 2015
  48. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    Heya,

    the first part works for me - in the Level_Desktop example, if I select the GUI gameobject in the hierarchy and expand the "Control" variable of GUIImpl, the "Tower Height" value defaults to 14. If I change it to 300, the camera flies really high in the air when controlling a tower (and stays there).

    The height limitation after leaving the tower actually comes from the camera script itself ("CameraControl", attached to the camera) and its zoom range setting. Good to see you've solved the second issue.
     
    MyOwnGames likes this.
  49. MyOwnGames

    MyOwnGames

    Joined:
    Jul 21, 2014
    Posts:
    25
    OMG! I had a Mathf.Clamp on my camera! Thank you very much for having reminded me to check this, didn't know how many time I could have spend before to notice it...

    Since I'm here, a really quick question. Sometimes the meshes of my enemies don't show up. For what I see, it depends of how many prefabs of my enemies I pre-load.

    For example if I pre-load 5 prefabs of a enemy, the mesh may not show up from the 6th prefab spawned and later. The enemy is instantiated in the Enemy's Pool Manager through a unused preloaded Clone of the prefab, but in the scene view I just see colliders without meshes running the path. But once they're killed, they appear and show up for their dying animation.

    I you have a idea. I come back to edit if I find the solution meanwhile, I didn't work a lot on it yet
    Thank you one more time!
     
  50. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,256
    I didn't notice this yet, but will try to reproduce it. Does it also happen in the example scene and with the prefabs included? Thanks!