Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Customizable Turret System

Discussion in 'Assets and Asset Store' started by ChrisSch, Sep 15, 2015.

  1. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Capture.PNG
    Turret System
    Turret System is a customizable script, allowing developers to easily set up their own custom turrets. It can be used in many cases such as shooter games, tower defense games, tank games as the gun of the AI tank, and others that require AI turrets.

    Turret customization options range from a few general types such as raycast (instant hit), projectile, homing projectile, laser, shock, and melee, expanding further into detailed customization such as damage, shot range, fire rate, and so on.

    Provided in the package are the Turret System scripts, some handy scripts, and over a dozen examples made out of a few placeholder models, and Unity's primitives. The ones you see on the picture above. :)

    Features:
    - Clean and commented script
    - Turret System main script
    - Turret System projectile script
    - Turret System health script, with health bar
    - audio self destruct script
    - constant rotation script
    - load scene script
    - 13 example turrets
    - 3 projectile ammo examples
    - 3 particle examples
    - 9 placeholder sounds

    Check bellow for more added features!




    2.PNG
    3.PNG
    6.PNG
    7.PNG
    Turret System

    Version 1.1 Log:

    - Prettier inspector
    - Tool tips. Hover over any option and youll get a description of it.
    - DPS feature (shows damage per second of your turret)
    - Top-Down player controls
    - First person player controls
    - Health bar for the TurretSystem_Health script
    - Simple handy load scene script for buttons (put it on empty GO or canvas, and drag it into buttons)
    - Added menu to test out scenes faster
    - Added 9 sounds
    - Improvements
    - Fixes, fixes, fixes :)

    Version 1.2 Log:
    - Optimized (added a frequency setting for OnTriggerStay(), making it almost 70% faster)
    - Added DPS for projectile type too
    - Added animation support
    - added ammo, clip ammo, and reload time
    - added turret angle limits for AI too
    - added particle turret

    Update v1.3:
    - Pooling (bullets, sparks, muzzle, explosion)
    - Target lead (aim ahead)
    - Visual Particle (bullet casings)
    - Move randomly when no target
    - Fire on button press/hold/release
    - Camera as origin for raycast attack (for FPS)
    - Small fixes and addons

    Update v1.4:
    - Min/Max horizontal angle limits
    - Mobile turret option (If checked pools won't be parented to the turret. Fixes weird rotations of projectiles on mobile turrets)
    - Turret Upgrade (for tower defense games)
    - Turret Upgrade Cost
    - Turret sell value

    Update v1.5
    - Third person view. Used in combination with first person view.

    Update v1.6
    - Fixed turret not losing track of target once it leaves the range trigger
    - Added an "Auto Fire" feature. Useful for cardboard
    - Optimized scenes
     
    Last edited: Jul 13, 2016
    Archania likes this.
  2. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Here's the pdf documentation, with a simple example tutorial. I tried to comment every line of code, but without cluttering the script or going overboard. :)
     

    Attached Files:

  3. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    All turret examples on display making fireworks. Sorry for no sound. :)


    The pack is done and waiting approval, but I'm already working on an update, that will allow the player to directly take control of the turret and aim either top-down or from first person. I have plans for the next few updates already, but lets take things slow. :)
     
  4. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Released! Turret System :)

    Now working updates for the turrets, and on a complete project asset pack, that will utilize the Turret System.
    Here's the first screenshot in Unity.
    upload_2015-10-6_18-12-18.png
     
    Last edited: Oct 10, 2015
  5. imtrobin

    imtrobin

    Joined:
    Nov 30, 2009
    Posts:
    1,548
    I think a demo is needed.
     
  6. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Working on a playable demo (the tanks game above) using the turrets, and video setting up one.
     
  7. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Top-Down and FPS turret controls are implemented. They are no longer just AI. You can take control of the turret with a simple checkbox!
    upload_2015-10-9_18-36-44.png

    Here's a short video demo.


    Another nifty feature I almost forgot to mention, is the new health bar for the health script. You can see it in the video.
    Simply make a world canvas, a prefab of the healthbar image, and drop it into the health script, along with the canvas. Or assign a "World Canvas" tag to the canvas, and the script will find and assign it automatically. You can also adjust the offset accordingly.
    upload_2015-10-9_18-43-1.png

    I'll polish and clean up a few more things and upload. Tomorrow I'll try doing a longer video demo.
     
  8. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    446
    looking for a turret system for my mobile game, is this mobile optimized?
     
  9. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    I'm not sure, its fresh out of the oven.

    If you mean the the top-down and 1st person player controls, then no, I didn't set up any mobile controls, but I think it should work by default, or with Unity's standard assets mobile controller script.
    As for performance, I'll do some tests now and see how it performs on my LG Optimus L7 II (which is meant for only 2D games, and weak 3D games), and another better phone.

    I tried making it as optimized as possible. Most of the variables, temporary or otherwise, are declared from start. And pretty much all that runs in Update, is checking for a target, a couple quaternions and vectors to calculate the rotation of turrets (head and pivot), and the rotation itself. The rest runs on demand.

    Note that the models are only placeholders, they are by all means not optimized for mobile.
     
  10. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    PS. Added a nifty new feature that calculates the DPS (damage per second) of the turret, so you can easily balance the power of your turrets within editor. As soon as you change a setting it calculates and shows at the bottom, no need to press anything. :)

    It runs only within editor, so its not an excess weight during runtime. It just takes the damage amount, rate of fire, and number of barrels into consideration. Simple but very useful for balancing. You can also call the function at runtime. I could think of at least one use (EVE Online has a DPS feature on its ships), but I don't want to make too many updates too fast. I have a lot lined up, and I'm excited about doing them.
     
  11. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Made a menu to switch between scenes so I made a new video too. Just messing around, maxed out everything to see if it'll still run smooth. :)

    Its locked at 60fps because VSync is on. In Editor its around 70-80fps (but stats as always show over 100fps). I'll make a mobile build now and see how it runs. But I won't optimize the models or particles, I'm sure it'll run fine even on my phone.

     
  12. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Alright done with the update. Plenty new things and improvements.

    Version 1.1 Log:
    - Prettier inspector
    - Tooltips. Hover over any option and youll get a description of it.
    - DPS feature (shows damage per second of your turret)
    - Top-Down player controls
    - First person player controls
    - Health bar for the TurretSystem_Health script
    - Simple handy load scene script for buttons (put it on empty GO or canvas, and drag it into buttons)
    - Added menu to test out scenes faster
    - Added 9 sounds
    - Improvements
    - Fixes, fixes, fixes :)

    Tested on my low-end phone and the script itself is running fine on 30fps (seems to hit a wall at 30fps like its locked). My phone can't run most 3D apps I find on the store smoothly, so I'm rather surprised it ran this well. :)

    I didn't bother optimizing the test scenes for mobile much, I just lowered all settings. The main scene is dying on 2fps (my partner got 10 there) because the scene is not at all optimized for mobile. All the turret placeholders you see are made out of cubes. There's 600-700 shadow casters in the main scene lol. The other scenes run fine on 26-30fps. The biggest toll is the models I guess.

    My partner has a 3 times better phone (not sure the name, its a local brand) but a bit less fps in some scenes, and almost 60 in the tutorial example scene. I guess it depends on the phone too a lot. :)
     
  13. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Latest video.


    Updated documentation, now I'll clean up and upload, and then work on a bit longer demonstration vid before making new updates.
     
  14. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Update 1.1 submitted, and documentation updated.
     

    Attached Files:

  15. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    446
    any chance you can upload the apk test you made so i can test it on my mobile?

    can the turrets be put on moving vehicles and still rotate / tilt independent of vehicle movement?

    can the turrets be fixed upside down to ceilings and sideways on walls?
     
    Last edited: Oct 11, 2015
  16. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    I'm not sure that's a good idea as apk files can easily be "unzipped". Plus I don't think my demo scenes are good. The turret examples are just placeholder primitives, each with its own material. Probably most of the lag comes from the unoptimized models, and the standard shader. There's like at least 10 draw calls per turret. :)

    I'm working on another pack (probably won't be done any time soon) that uses the Turret System for turrets on tanks, and for the player tank, in a top-down view. I'll test that too on mobile now.

    Yes absolutely. Exactly what it does in the above mentioned game. I'll record and post here.

    Yes. For the AI, the rotation doesn't matter. For the player turret, I guess sideways would be a problem, because there's no angle limits on horizontal axis at the moment. Haven't tested it. But upside down should work.
     
  17. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    446
    thanks for the info, i will mostly be using missiles, is there a variable fly speed for these and multiple positioning for turret missiles and are the positions picked at random to fire each missile untill they are all fired.
     
  18. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Missiles use the same script as the projectile script. You just check the "Is Missile" box and it becomes a missile.

    upload_2015-10-11_17-58-10.png

    Turret System started from a tower defense game, so they have infinite ammo, but limited ammo is on the list to come in the next few updates. If the turret has multiple barrels (muzzle positions), the projectiles are fired from a random muzzle position.

    And yes you can tweak the speed, range, and turn speed of the missile. The higher the turn speed the more likely it is to hit the target. Low turn speeds can end up in some hilarious results, with missiles flying around the target, unable to hit it. If the target dodges one fast just before it hits. :)



    And here's the projectile turrets in action in that tank game I mentioned. Runs the same as other scenes on my phone. Around 26-42fps. Average 30fps. Its a bit better this time because I changed the standard materials to diffuse, and mobile diffuse.

    Here's a few mobile screens I took before they killed me.
     
    Last edited: Oct 19, 2015
  19. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Video tutorial is out. :)



    Takes around 2 minutes to set up a turret after watching the tutorial.

    Turret System
     
  20. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Working on the next update v1.2.

    Done so far:
    1. Optimized more. Added a check in the OnStayTrigger, to not execute every frame. which seemed to be causing around 10-12ms in the Physics.ProcessReports in the main scene. Now that's been cut down to around 0-2ms, sometimes 3. Everything else related to the script is less than 1ms total I think. On my mobile its slightly better but it cant pull more than 30-40fps because of the weak gpu. On the PC however it went up to around 200fps. I think the script is super fast, I just wish I had a better phone that doesn't care about the graphics requirements to test it on, so I know for sure its mobile ready too. Mine is almost strictly 2D games only. But then again what is mobile optimized? What are the standards? Its pretty different depending on the case if you ask me. Thought I'd make a thread and ask about it.

    2. Added DPS calculation for projectile turrets too.

    3. Added total ammo, magazine ammo, and reload time. I think you wanted limited ammo @melonhead .

    4. And finally animation support. This one is still in WIP stage, but almost there.

    There's a few more things I wanna add before I submit this update.
     
  21. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Animation support is done. I'm now gonna finish up with the particle turret, and be done with version 1.2.
    Still waiting for them to approve of v1.1. :D

    In 1.3 I'll try implementing pooling for starters, for the projectile turret. I never done pooling before.
     
  22. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Version 1.2 Overview:
    - Optimized (added a frequency setting for OnTriggerStay(), making it almost 70% faster)
    - Added DPS for projectile type too
    - Added animation support
    - added ammo, clip ammo, and reload time
    - added turret angle limits for AI too
    - added particle turret (2 examples, flamethrower and gattling-laser-gun)



    Turret System
     
  23. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Version 1.1 released! Submitting v1.2.
     
  24. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Updated documentation for v1.2. :)
     

    Attached Files:

  25. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
  26. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    446
    About 4 of the included scenes do not work properly including the main scene with the line up, none of the enemy cubes are tagged in the editor, they only seem to become tagged when in play mode, how is this? , this needs to be fixed as i would be using this scene to look through to see how the items and scripts are put together, i am using unity 5.1.2f1, all turrets in all scenes start with a detection radius of 0.5 and will not work till i have to manually increase it, when you buy an asset you expect the included scenes to work without having to manually change settings, on one of the scenes when you move the enemy cube above the turret level it then points down and when move enemy cube down turret then points up, can you please test these and fix them for the next update thank you
     
    Last edited: Nov 11, 2015
  27. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Hi! Yes they're not tagged because, as far as I know, there is no way to include tags or layers in an asset, unless you upload it as a "Complete Project". In which case everything you have set up, your own tags and layers, will be overwritten by mine in order to function, because most people don't start off their game project with an asset. I placed a note saying you have add the tags and layers. If you know a better way of doing this please let me know. Is there anything else not working?

    As for the sensor colliders, that's not suppose to happen. They're suppose to automatically increase when the game starts giving you less to worry about, based on the "Shot Range". I tested with 5.0.1 and 5.2.2, but I'll look into it again. And they're set to 0.5 so you can easily navigate the scene, and when you press F to zoom in on the turret, it actually zooms in, and not out, to include the whole 10 unit collider.

    Yes you're right about the "Setup Tutorial" turret pointing down. The angle limits are set to 30 and -30, but they should be -30, and 30. I noticed that and its fixed in v1.3.
     
  28. AppThing_Dev

    AppThing_Dev

    Joined:
    Jun 9, 2014
    Posts:
    9
    NOTE: You can ignore this post I just re-read your comment above and swapped the Min Angle and Max Angle and it seems to have fixed the issue. I should RTFM a little closer in future :-D

    Hi,

    I just bought this asset. Looks pretty cool, but as per melonhead's observations I cant get the initial scene to work :( I have added a Layer called 'RangeCollider' and set the TargetSensor as being on that layer.

    I have also added two tags called Enemy and AirEnemy and set the Cube to be the Enemy tag.

    I then excluded the RangeCollider from the 'Obstacles Layer Mask'.

    When I play the scene the gun fires but it tilts up aiming away above the Cube? if i move the cube the turret does seem to rotate to follow the position of the cube, but never hits it.

    any thoughts what could cause this?

    BTW: this is Unity 5.2.2 I just created a new empty 3D project and imported your asset.

    Thanks.

    Paul.
     
    ChrisSch likes this.
  29. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Hi, glad you worked it out. The fix is coming in v1.3. I'll try to make the need for layers and tags clearer. Its in "Important Note" but I'll also add it as the first thing in the instructions pdf.

    Also bullets, sparks, and muzzle flashes will all be pooled in v1.3, so everything should work even faster. No more instantiate and destroy. :)
     
  30. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    446
    as i said on the main scene when you press play the tags are there as they should be but when not playing the tags say undefined or similar so this is a bit strange, just extending the range spheres for all turrets will make it play properly so the tags have been saved with the asset they just dont show when not playing, be glad to see the update though so i dont have to mess about, so far from what i have played with it is looking good, any optimization will be good for me as i am using this on mobile.
     
  31. AppThing_Dev

    AppThing_Dev

    Joined:
    Jun 9, 2014
    Posts:
    9
    I have a feature request for you. :) (already...)

    How difficult would it be to add an X pivot and Y Turret pivot parameter on your script? so that if only pivotX is selected it uses it as the full 360 pivot point (as per the script does now) but if a pivotY transform is chosen then pivotX is only used for left right motion and pivotY for up down?

    the reason I ask is my turret models I want to use, have a kind of U shaped holder that the weapon is mounted into and at the moment it looks odd when it pivots up/down as the whole U base tilts on it's base whereas I just want the head to move up/down. - hopefully that makes sense?
     
  32. AppThing_Dev

    AppThing_Dev

    Joined:
    Jun 9, 2014
    Posts:
    9
    ok.. again RTFM :) I looking at the source code I can see that the pivot is Y only and the head is X I just had to break apart my prefab and move elements around... (sorry) all good now!
     
  33. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Hows the current version working on mobile?

    Yes the head and pivot should be separate objects, but the pivot is just a visual part. If you want the head to tilt up and down, check the "Allow Tilting Forward", if you don't, it will be locked on the X plane. :)
     
  34. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    446
    not actually tested on my mobile yet as i am still setting scenes up, but when i have completed i will publish results

    would be good if you could add a script that randomly moves the turret around when there is no target in its range so it dont look so the turret dont look so dead

    the main problem i have come across is the damn 3ds max which uses z axis as up instead of y axis, getting these to convert to the fbx is not good
     
  35. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Yes that's a good idea, I'll add it to the (already big) list of future updates. Just trying to get the important stuff out of the way first.
    Yes, I know your pain, Blender is the same. And most other 3D editors I assume. The easiest way to fix it is to just ignore the issue in the 3D editor you're using, and then just parent the mesh under a correctly rotated empty game object in Unity. You get way more control and clarity like that. That's how all the turrets are set up in the example scenes.
     
    Last edited: Nov 13, 2015
  36. melonhead

    melonhead

    Joined:
    Jun 3, 2014
    Posts:
    446
    i will give it a try, still dont understand how all the 3d packages have z-up and y as depth, very strange seing as even since school 30 years ago time lines and graphs always used x horizontal and y vertical
     
  37. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    So yeah, pooling is done, also added a neat little add-on, particle casings. Ability to shoot out particles along side other turret types, purely for visual purpose, such as bullet casings. And other cool stuff below.

    Update 1.3 features (so far):
    - Pooling (everything is pooled, bullets, sparks, muzzle flash, explosions)
    - particle addon (release bullet casings, smoke and alike while shooting)
    - FPS camera origin (first person mode was available from previous update, but wasn't ideal for FPS games, but now it is! The bullet origin can come from the camera, meaning you'll always shoot towards the center of screen, while muzzle and the rest comes from their respectful positions still)
    - and upon your request @melonhead , I added a non-static idle state for turrets that have no target. simply change the interval to something other than 0 and the turrets will move randomly when they don't have a target

    This is ofc all optional. Now all that is left for this update is the aim-ahead of moving target ability.

    PS. If the scenes aren't working correctly. Check out the note I attached in this post. It will be included in instructions and the update.

     

    Attached Files:

  38. AppThing_Dev

    AppThing_Dev

    Joined:
    Jun 9, 2014
    Posts:
    9
    Hi,

    Is there support for triggering external scripts or methods on a hit/damage? Or if i was to extend the script what is the best function to override to achieve this?

    thanks.
     
  39. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Hi, can you be more specific?

    If you want something happening to the turret, you can open the turret, projectile, or health script and add the line of code you want happening when damage is applied. You can search for "TakeDamage" in any of those scripts, then throw whatever you need there, after or before it.

    If you want something happening to the target, and you're using the TurretSystem_Health script, just put your code somewhere in the TakeDamage method of it.

    I've been thinking about adding an optional custom trigger with SendMessage(), but its slower than GetComponent().
     
    Last edited: Nov 22, 2015
  40. TonanBora

    TonanBora

    Joined:
    Feb 4, 2013
    Posts:
    493
    Hey there Chris!
    I tried to setup a turret, but no matter how long the turret's range, it never picked up a target unless the target was right on top of the turret.
    Even in the demo scenes this happened.

    Upon testing, I noticed that the Sensor's sphere collider was not being modified based on the turret's range.
    Once I increased the collider's radius manually, the turret had no trouble finding a target.

    EDIT:
    Also, the projectiles and missiles do not work for me either. They spawn, then collide with something right after spawning in, and detonate.
     
    Last edited: Nov 23, 2015
  41. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Hey, take a look a few posts up, or the "Important Note.txt" in the Turret System folder. This version is more detailed than the one in v1.2 (it'll be in v1.3). Those are a couple steps you must do before it will work properly. It takes a couple minutes to set up at most.

    The script looks for a sphere collider somewhere on the turret, or childs, on a layer named "RangeCollider", and if it finds it it will automatically expand the collider based on range. The other thing in the note is important too so check it out. :)
     
  42. TonanBora

    TonanBora

    Joined:
    Feb 4, 2013
    Posts:
    493
    Ah, my bad. :p
    Is there a way to set it so that you can make turrets that are, say, mounted upside down?
    I have set up some turrets on the underside of a space ship, but upon pressing play, they turn right side up, and end up inside the ship.
     
  43. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Hey, sorry it was 4am for me when you asked that. :D
    Yes sure, just make an empty game objects rotated correctly, and put your head/pivot models as childs of them, and it should work. Like so.

    upload_2015-11-23_9-55-24.png
     
  44. AppThing_Dev

    AppThing_Dev

    Joined:
    Jun 9, 2014
    Posts:
    9
    Hi,

    I'm using a 3rd party set of scripts to track damage, health, lives etc so was hoping to not have to use the TurretSystem_Health scripts. A custom trigger sounds great! In the meantime I have created a file that extends TurretSystem_Turret and overrides Start and RaycastAttack. (I had to edit the original TurretSystem_Turret file to make them "public virtual" to allow me to override them, which will be a pain on any of your future updates....

    So... A better option (which I suspect would take you no time to do) would be to create a public virtual method in TurretSystem_Turret called TriggerDamage that would allow people to override it currently it could either be empty or perhaps read as:


    Code (CSharp):
    1.  
    2. public void TriggerDamage(GameObject hitGO, float damageAmount) {
    3.     hitGO.GetComponent<TurretSystem_Health>().TakeDamage(damageAmount);
    4. }
    5.  
    and then in your file replace the instances of:

    hitGO.GetComponent<TurretSystem_Health>().TakeDamage(damageAmount);

    with

    TriggerDamage(hitGO, damageAmount);

    Also as your scripts are expanding, I would suggest you them into their own namespace e.g. TurretSystem

    But in the meantime, I want to thank you for these great set of scripts they are awesome, i cant wait for the 1.3 to come out on the asset store. I'm keen to see the no target random moving turrets working.

    Regards,

    Paul.
     
    ChrisSch likes this.
  45. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Thanks! I'll have to look into that. I'll definitely add the SendMessage for attacks, and make it clear that its way slower than GetComponent(), in the tool tip. So overriding, or simply adding your line of code should be better. Some people like me want to fire bullets every 0.1 sec. :D
     
  46. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    I changed it per your request and it'll be in the next update. This is how that part will look like. Also threw in a message option there. It'll work for all of the turret types, not just raycast. Same thing can be found in the projectile and particle scripts now, because they have to be separate.

    Code (CSharp):
    1. public virtual void TriggerDamage(GameObject hitGO, float damageAmount)
    2.     {
    3.         hitGO.GetComponent<TurretSystem_Health>().TakeDamage(damageAmount);
    4.         if(customScriptToSendMsgTo != "")
    5.             hitGO.SendMessage(customScriptToSendMsgTo);
    6.     }
     
    AppThing_Dev likes this.
  47. AppThing_Dev

    AppThing_Dev

    Joined:
    Jun 9, 2014
    Posts:
    9
    Looks good, thank you very much.
    Although I would expect the SendMessage line to read:

    try again...
    Code (CSharp):
    1.     hitGO.SendMessage(customScriptToSendMsgTo, damageAmount);
    2.  
     
  48. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Yeah I thought about that, but since we already have override for that, why use sendmessage too? I thought send message could be maybe used for something other than applying damage when the target is hit. Not sure, the asset was just recently released, so not many active users yet to share their opinions, and I wanna make it as customizable as possible, not tailored for one purpose. But theres a limit to how customizable you can get before the options become "just the little things" everyone wants different, and a lot of them, if you know what I mean. :D
     
  49. AppThing_Dev

    AppThing_Dev

    Joined:
    Jun 9, 2014
    Posts:
    9
    Yeah I understand... :)

    It's up to you at the end of the day.

    For me I think for most people being told damage has occurred is useful, but being told how much damage is even more useful. Or... maybe give them the choice? At the point they enter the method to call (as I understand it SendMessage requires a Method not a script name) give them a boolean checkbox to say Send Damage Details as Float or similar.

    As I say it's up to you. Personally I will probably override the whole method for my use, but others might not understand how to achieve that (or even want to). That what I like about the Unity community there's such a wide range of levels of knowledge and yet everyone always seems willing to help each other. V.Cool ! :-D
     
  50. ChrisSch

    ChrisSch

    Joined:
    Feb 15, 2013
    Posts:
    763
    Yeah. I'll keep it in mind for when I make a better inspector with tabs and stuff. Its getting sort of crowded with the new options atm. With the amount of options right now the inspector can't fit the 1080 height of my screen. :p

    Btw it would be cool if you could review it on the store after you're done experimenting with it. :)
    And if you make something out of it, feel free to post here, even if you're just messing around. I'm interested in seeing what other people do with it.
     
unityunity