Search Unity

[Released] DestroyIt - Cinematic Destruction System

Discussion in 'Assets and Asset Store' started by DeadlyAccurate, Jun 14, 2014.

  1. StephenSpanner

    StephenSpanner

    Joined:
    Aug 18, 2015
    Posts:
    3
    It works! I think part of the problem was that I wasn't putting the cling-points close enough. Once i moved them around, it seems they now cling properly. I also made the beams kinematic so they won't topple over with the roof-chunks unless smashed from below.

    Thanks for the hasty/awesome response! You guys rock!

    Smash!!!

    PS - The gas pumps obviously explode and cause further damage, yay!
     
    zangad and DeadlyAccurate like this.
  2. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    Wanted to drop by and say that this a wonderful asset. The object management and destructible framework is intuitive and easy to setup .Well done!

    I'm having a bit of a conflict between my destructibles and the player vehicle in my game. When I ram a destructible group of wood posts, the ensuing destruction tanks the velocity of the car to zero.

    When I disable the destructible part, effectively leaving the group as a collection of posts connected by fixed joints, the truck has no problem driving through them.

    Here is a video of what I described above:


    Here are a few things I've tried to fix the problem:

    • Lower the mass value on all destroyed game objects
    • Lower the force and torque values on the fixed joints
    • Increase the maximum speed of the vehicle
    • Increase the mass of the vehicle.
    I am currently using Edy's Vehicle Physics to implement the truck physics. Any insight you can offer would be greatly appreciated.
     
    DeadlyAccurate and zangad like this.
  3. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi Ledbetterman,

    Thank you for the kind words. It really means a lot to us.

    Regarding the issue you're having, I have an idea as to what might be going on. There's a function in DestroyIt called ReapplyImpactForce(). What it does is, if an object collides with and destroys a Destructible object, it re-applies that object's previous momentum to make it "punch through" the destroyed object. It's typically pretty helpful for uncontrolled, free-moving objects in your game.

    But since you're actually controlling the colliding object yourself, you don't want something taking control of your rigidbody and brute-force controlling its momentum. So as a test, could you try commenting out this section of code and seeing if it helps?



    If that doesn't help, is it possible to upload your project somewhere so I can take a look at it? I don't have Edy's Vehicle Physics, so I can't setup a test of this myself.
     
    Last edited: Sep 18, 2017
  4. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    That fixed it! Thanks for the quick response. I was actually just taking a look at that particular piece of the destructible script when I saw your post. Nice timing :)

    Just so I understand what's going on, this bit of code basically prevents an object from losing it's momentum, right?

    I probably plug in some checks to ensure this code ignores the car, but still works properly on non-controlled objects.
     
    Last edited: Sep 10, 2015
    DeadlyAccurate and zangad like this.
  5. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Yes, exactly. If you left that code commented out, then something like the cannon's cannonball (in the demo scene) would stop dead or bounce off any Destructible object it destroys. As far as the cannonball is concerned, it was a solid collider at the time of impact, so it did it's job by reacting appropriately to it (bouncing off or stopping dead). It's just not what we expect visually from a destroyed object, though.

    With the ReapplyImpactForce() function, we're just overriding that behavior, so it zeros out any reactive velocity and vector it might have had, and instead we send it right through the object with its previous velocity and force vector.

    So yeah, I think you're right on track to have the function check for and ignore cars, but operate normally otherwise. I was going to suggest that myself if it had fixed the issue, but you're way ahead of me. :)
     
  6. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    Thank you very much for your help, Zangad.
     
    DeadlyAccurate and zangad like this.
  7. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    Hey Zangad & Deadly, out of curiosity, have ya'll ever tested DestroyIt with SpeedTree assets? I'd like to implement broken limbs on trees and I'm considering using Unity's SpeedTree integration to take advantage of its fancy wind effects. Thought I'd check in to save myself the headache in case its been proven unreasonably complicated.
     
  8. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    When SpeedTree first came to Unity (with the Unity 5 rollout, I think?), I was going to replace the palm tree in the demo scene with the SpeedTree one, which looks much better. But the problem is, the SpeedTree assets are closed - meaning you can't get to the mesh - and I needed the mesh in order to break the tree at the stump and have the treetop fall over realistically.

    I figured it was just my lack of knowledge on how SpeedTree works, so I did some digging around at the time and it turns out you have to subscribe to the SpeedTree Modeler for $19/mo in order to export the mesh so you can create a destroyed version from it. And even if I subscribed for a month to make a destroyed version of the SpeedTree palm tree, I don't think we'd be allowed to package it with DestroyIt, because we'd be effectively giving away the mesh, and I think the closed architecture on their assets is intentional.

    So I stopped pursuing it after that. But for your game, it might work fine. Using the SpeedTree modeler, you could export the mesh and break the tree into branches/stumps/etc, and bring it back into Unity to put rigidbodies and colliders on the pieces to make your destroyed version.

    If you don't really need the branches to be debris (as in, players can't pick up the branches and use them for crafting) you might consider doing a leaf and branch particle effect similar to the palm tree in the demo scene. After a certain amount of damage, some leaves and branches fall, but it's just a particle effect (check out the Damage Level Effects in DestroyIt). And when your tree is destroyed, it could act like the trees in 7 Days to Die and explode into a leaf/branch particle effect. That way you wouldn't need to export the SpeedTree meshes or create destroyed mesh prefabs. It would be a different look, though, so it depends on the type of game you're making if that would fit.

    Anyway, I hope that helps. Definitely keep us posted on your progress with destroyed SpeedTree assets. I'd still love to replace the palm in the demo scene with a SpeedTree one!
     
    led_bet likes this.
  9. led_bet

    led_bet

    Joined:
    May 5, 2015
    Posts:
    83
    Great to know. I'll look into the speedtree modeler and report back if I have any fruitful results. Thanks!
     
  10. nxtboyIII

    nxtboyIII

    Joined:
    Jun 4, 2015
    Posts:
    281
    Hi,
    in the demo scene, did the destructible wooden tower use any joints? I want to use this asset for mobile and I want destruction like that but I don't know how well it will run. Thanks!
     
  11. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Quick question. Does the package handle LODS? can you LOD out the objects/destroyed parts of the objects after they have been damaged?

    Thanks!
     
  12. wwg

    wwg

    Joined:
    Apr 2, 2014
    Posts:
    130
    Hi,
    I'd like some opinions (from the developers or the community) on the following:

    1. Would DestoryIt be a good solution for a general vehicle damage system?
    Example: I want my vehicle to show progressive damage as it collides with terrain, trees, and other objects in my scene, not just when I'm totally destroying it (shooting, explosions, etc.).
    [EDIT: It works well for this. After buying the asset and spending some time with the SUV example it started making sense. Just add a box collider and 'Destructible' script to the mesh on your model. Adjust the Hit Points as needed and then specify the desired damage.

    2. I understand that destructible trees need to be regular game objects. Is it plausible to dynamically replace the terrain trees near the character with identical game object trees that can be destroyed?
    Example: all the trees near the vehicle will become destructible, so my vehicle can crash into and damage them.

    3. I don't see any support for dynamic mesh deformation...has anyone used this system in combination with an asset like Impact Deformable (or a similar deforming script)?
    [EDIT: a previous post in this forum suggests that deforming scripts might work well with DestroyIT, but I haven't tried it yet.}


    Thanks!
     
    Last edited: Oct 21, 2015
  13. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    Yes, it can handle LODs. Here's a quick image showing the wall from the demo scene. At LOD 0, both the wall and lamp are visible. At LOD 1, I culled the lamp. LOD 2 has no additional culling, but it still has the progressive damage of the destroyed pieces.

     
    Last edited: Jul 3, 2017
  14. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Great thanks!
     
  15. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi there,

    Yes, the destructible wooden tower in the demo scene does use Fixed Joints. However, you don't have to use joints - you could just parent the supports to each other and make a stiff framework that way. You could also leave them as joints and reduce the Solver Iteration Count to 6 or so, and it would greatly improve mobile performance at the cost of having "springy-er" joints. I would guess it mostly depends on how many joints you think you'll need in your mobile game. A few dozen in the scene at once with a low solver iteration count probably wouldn't be an issue. Hundreds probably would, though.
     
  16. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    That sounds plausible. The only issue I can think of would be the noticeable shift that would occur because of differences in tree swaying from the Terrain tree and the regular object tree. Even if the trees are identical and the rotation and position is exact, it would be difficult to sync up the swaying. Of course, this may not be an issue depending on what type of game you're making. It wouldn't be as noticeable in a top-down isometric game, and wouldn't be noticeable at all if you're not using tree swaying shaders.

    No, DestroyIt doesn't come with any mesh deformers out of the box. But we have used DestroyIt with Edy's Vehicle Physics, since Edy's has a mesh deformer damage system built in. It worked well - the cars would get banged up and crumpled from Edy's, and the bumpers would fly off and windows/headlights shatter from DestroyIt. The only issue we ran into was with large explosions that damaged the entire car at once (we got some significant lag on the mesh deformer - it probably wasn't designed for explosions). But overall, the two worked very well together.
     
  17. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    I don't understand this question. Did you click on the wrong thread perhaps?
     
  18. nxtboyIII

    nxtboyIII

    Joined:
    Jun 4, 2015
    Posts:
    281
    Oops, wrong thread, sorry :S
     
  19. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi everyone,

    A customer had a question about how to monitor hit points of a destructible object and do other things when the hit points reach a certain point. I thought it was a great question and would like to share the resolution, in case anyone else is struggling with this.

    Question:
    Solution:
    There are two ways I can think of to check current hit points of destructible objects. One is to create a separate game object that monitors the destructible objects. The heads up display in the DestroyIt demo scene currently does that, and is a good example of how you would monitor several object's hit points and do something when they reach a certain point. To get it working, you need to check the Debug Monitor checkbox on the Destructible script, and then hit 'H' while in game to bring up the HUD.



    In the game, it looks like this, giving you the (x,y,z) vector location of the destructible object and it's current hit points.



    Take a look at HeadsUpDisplay.cs attached to the main camera in the DestroyIt demo scene if you're interested in going this route.

    The other way is to attach a script to the destructible object itself, and check hit points and fire events from there. The one gotcha about this approach - and possibly the issue you ran into where it wasn't working for you - is that if the destructible object gets destroyed, the scripts that are on it won't run because the game object is gone. The way around this is to use the OnDestroy() method in your script, which will fire right before the object is destroyed.

    I've created a script called MonitorHitPoints that illustrates this approach. Just put this script on a Destructible object and it'll log to the console when the object is at half hit points, zero or fewer hit points (for when the CanBeDestroyed checkbox is unchecked), and when the object is destroyed.

    Code (CSharp):
    1. using UnityEngine;
    2. using DestroyIt;
    3.  
    4. /// <summary>
    5. /// Put this script on a Destructible object to fire events when its hit points reaches specified thresholds.
    6. /// </summary>
    7. public class MonitorHitPoints : MonoBehaviour
    8. {
    9.     private Destructible destructibleObj;
    10.     private bool zeroHitPointsEventFired; // Have we fired our event for when the destructible object's current hit points is zero or less?
    11.     private bool halfHitPointsEventFired; // Have we fired our event for when the destructible object's current hit points are at half?
    12.  
    13.     private void Start()
    14.     {
    15.         // Get the Destructible component on this game object.
    16.         destructibleObj = gameObject.GetComponent<Destructible>();
    17.  
    18.         // If it doesn't exist, log a warning to the console and remove this script.
    19.         if (destructibleObj == null)
    20.         {
    21.             Debug.LogWarning("No Destructible object found on game object [" + gameObject.name + "].");
    22.             Destroy(this);
    23.         }
    24.     }
    25.  
    26.     private void Update()
    27.     {
    28.         // Check current hit points of the destructible object, and if it's half or less, do something.
    29.         if (!halfHitPointsEventFired && (destructibleObj.currentHitPoints / destructibleObj.totalHitPoints) <= 0.5f)
    30.         {
    31.             // Do something here...
    32.             Debug.Log("Destructible object [" + gameObject.name + "] is currently at HALF hit points!");
    33.             halfHitPointsEventFired = true;
    34.         }
    35.  
    36.         // Check current hit points of the destructible object, and if it's equal to or less than zero, do something.
    37.         // NOTE: a destructible object could have its CanBeDestroyed flag set to FALSE, making it zero or fewer hit points but not destroyed.
    38.         if (!zeroHitPointsEventFired && destructibleObj.currentHitPoints <= 0)
    39.         {
    40.             // Do something here...
    41.             Debug.Log("Destructible object [" + gameObject.name + "] currently has ZERO or fewer hit points!");
    42.             zeroHitPointsEventFired = true;
    43.         }
    44.     }
    45.  
    46.     private void OnDestroy()
    47.     {
    48.         // This will happen when the destructible game object is destroyed.
    49.         // NOTE: you could also fire the "half hit point" event here too, if it made sense to do so for your game.
    50.         if (destructibleObj != null) // make sure we aren't just removing the script for a different reason.
    51.             Debug.Log("Destructible object [" + gameObject.name + "] has been destroyed!");
    52.     }
    53. }
     

    Attached Files:

    Last edited: Sep 18, 2017
    wwg likes this.
  20. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Another question came in from a customer regarding UFPS integration with DestroyIt, this time specifically for hitscan bullets. We thought the solution might benefit others, so here it is.

    Question:
    Solution:
    In the UFPS solution, open the vp_HitscanBullet.cs file and comment out lines 183-194 (the "do damage" section). Add the following code under it:
    Code (CSharp):
    1. DestroyIt.Destructible destObj = m_Hit.collider.gameObject.GetComponentInParent<DestroyIt.Destructible>();
    2. if (destObj != null)
    3. {
    4.     var impactDamage = new DestroyIt.ImpactInfo()
    5.     {
    6.         Damage = Mathf.RoundToInt(Damage),
    7.         AdditionalForce = 300f,
    8.         AdditionalForcePosition = m_Hit.point,
    9.         AdditionalForceRadius = 1f
    10.     };
    11.     destObj.ApplyImpactDamage(impactDamage);
    12. }
    Here's what it should look like when you're done:



    (Note: you don't have to add the AdditionalForce values. I just added it because I like objects to break with a little gusto.)

    I dropped one of our DestroyIt destructible columns into the UFPS SkyCity demo scene and took a quick video of the results:

     
    Last edited: Sep 18, 2017
  21. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    Minor update v1.3.5 is available on the asset store.
    • Fixed the Particle Alpha Blend (No Fog) shader for Unity 5.3, so textures using that shader no longer appear pink.
     
  22. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    192
    First off, just want to say great job on building an amazing asset! Extremely helpful for my project and saves me a TON of time!!

    However, I'm having 1 small issue I'm hoping you can help me with. I have a special scenario where I need some of the debris to go to a different layer. How can I change this? Basically, I just want to put the glass shards on their own layer so they can ignore physics on my character layer.
     
  23. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi HakJak,

    Thanks for the kind words. We're glad you're enjoying DestroyIt so far!

    Here are the steps for putting debris tagged as "Glass" onto the Glass layer instead of the DestroyItDebris layer:
    1) Create a new layer called "Glass".
    2) On the DestructionManager.cs script, look at line 415 or so.
    Change this:

    ...to this:

    Code (CSharp):
    1. // Assign each piece of debris to the Debris layer if it exists.
    2. if (debrisLayer != -1)
    3. {
    4.     GameObject go = debrisRigidbodies[i].gameObject;
    5.     if (go.HasTag(Tag.Glass) || go.tag == "Glass") // If the debris is tagged as Glass, save it to the Glass layer, instead.
    6.         go.layer = LayerMask.NameToLayer("Glass");
    7.     else
    8.         go.layer = debrisLayer;
    9. }
    3) Run the scene and break glass. Assuming your debris pieces have been tagged as "Glass", you should see that they are now in the Glass layer instead of the DestroyItDebris layer.

    I hope that helps. Let me know if you have any issues getting it to work.
     
    Last edited: Sep 18, 2017
    MarcusWatson likes this.
  24. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    192
    Thanks for the quick reply! If you don't hear back from me then you can assume that everything worked out well :)
     
  25. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hey everyone,

    A customer had a question about how to integrate a script he'd bought (Earthquake generator) with DestroyIt in order to create earthquakes that have realistic damage/destruction in his game. Now I don't own Earthquake generator, but I would assume from the description that it shakes the camera and jostles rigidbodies around. The only thing left would be to do damage to all the destructible objects in the area. So I wrote a quick script that does waves of damage to all destructible objects in the scene with the push of a button.

    We thought we'd share the earthquake damage script here, in case anyone is working on a similar project, or just needs inspiration.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. namespace DestroyIt
    4. {
    5.     public class EarthquakeDamage : MonoBehaviour
    6.     {
    7.         [Tooltip("The number of times waves of damage will wash over all the destructible objects in the scene.")]
    8.         public int damageWaves = 10;
    9.         [Tooltip("The amount of time (in seconds) between each damage wave of the earthquake.")]
    10.         public float damageWaveInterval = 0.33f;
    11.         [Tooltip("The amount of damage to apply to all destructible objects during each damage wave.")]
    12.         public int damagePerWave = 5;
    13.    
    14.         private Destructible[] destructibles;
    15.         private int damageWavesInit;
    16.  
    17.         private void Start()
    18.         {
    19.             damageWavesInit = damageWaves; // Store the inital number of damage waves.
    20.         }
    21.  
    22.         private void Update()
    23.         {
    24.             // In our example, the "0" key is going to trigger an earthquake.
    25.             if (Input.GetKeyUp("0"))
    26.             {
    27.                 // Find all the Destructible objects in the scene and do waves of damage to them.
    28.                 destructibles = FindObjectsOfType<Destructible>();
    29.                 InvokeRepeating("WaveOfDamage", 0f, damageWaveInterval);
    30.             }
    31.         }
    32.  
    33.         private void WaveOfDamage()
    34.         {
    35.             for (int i = 0; i < destructibles.Length; i++)
    36.             {
    37.                 if (destructibles[i] != null)
    38.                     destructibles[i].ApplyImpactDamage(new ImpactInfo {Damage = damagePerWave});
    39.             }
    40.  
    41.             if (damageWaves > 0)
    42.                 damageWaves -= 1;
    43.             else
    44.             {
    45.                 CancelInvoke("WaveOfDamage");
    46.                 damageWaves = damageWavesInit; // Reset the number of damage waves for the next earthquake.
    47.             }  
    48.         }
    49.     }
    50. }
    We also made a video of the results:

     
    Last edited: Sep 18, 2017
    HakJak likes this.
  26. Theekshana-A

    Theekshana-A

    Joined:
    Sep 27, 2014
    Posts:
    81
    Hi there, I cannot find a ApplyDamage method on UFPS Melee Damage script. How would I got about integrating UFPS now?
     
  27. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi Theekshana,

    In UFPS, the vp_DamageHandler.cs file now contains an OnCollisionEnter method at line 377 that calculates and applies impact damage. This method is where you would inject your code to check for destructible objects and apply damage to them.
     
  28. Theekshana-A

    Theekshana-A

    Joined:
    Sep 27, 2014
    Posts:
    81
    So if I replace everything in that method, I should be good to go right?
     
  29. Theekshana-A

    Theekshana-A

    Joined:
    Sep 27, 2014
    Posts:
    81
    There is the issue your old applydamage doesn't work with the new collidor system because it was made to raycast, can you send me the updated version of the code.
     
  30. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    DestroyIt 1.4 is now available for download on the Unity Asset Store.

    Changelog:

    Added: DestroyIt - Ready. You can now make your own DestroyIt objects for commercial purposes.
    Added: Skinned Mesh Renderer support for non-organic skinned mesh renderer objects.
    Fixed: Warnings for deprecated properties and methods from Unity 5.2 and 5.3
    Fixed: Mouse cursor not immediately visible when running in Unity editor and pressing Esc.

    DestroyIt - Ready


    If you'd like to make DestroyIt-ready destructible objects and sell them on the Unity Asset Store, now you can! You'll find the DestroyIt - Ready folder in the 1.4 package that includes a 3-page .pdf explains how to ready your destructible objects for commercial sale using DestroyIt.

    Skinned Mesh Renderer Support


    DestroyIt now supports destruction on non-organic skinned mesh renderers such as blinds, mattresses, flags, and robots. Check out #24 and #25 in the Demo Scene for examples of bone-rigged objects that can be destroyed. Note that trying to use DestroyIt on organic objects such as humanoids will have unpredictable results.
     
    julianr likes this.
  31. julianr

    julianr

    Joined:
    Jun 5, 2014
    Posts:
    1,212
    Nice update, and support for Earth Quakes :)
     
    DeadlyAccurate likes this.
  32. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I just discovered this and it looks amazing. I will definitely be picking this up for my projects.
     
    DeadlyAccurate likes this.
  33. Theekshana-A

    Theekshana-A

    Joined:
    Sep 27, 2014
    Posts:
    81
    Hi there, you might have missed my previous post but where would make the changes in UFPS to intergrate with DestroyIT. It still isn't very clear to me how I would inject the code in to the vp_DamageHandler.cs script? I am very new to C#. :)
     
  34. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi Theekshana,

    The elegant way to integrate DestroyIt with UFPS would be to add hooks into UFPS's damage handler, but that would require familiarity with how UFPS's damage handler works, as well as a good understanding of C# to extend the system for your game.

    But here's a quick way to do it without using UFPS's damage handler or needing to know any code:

    1) Create a new project, import both DestroyIt and UFPS.
    2) Open the DestroyIt demo scene, delete the FirstPersonController from the scene, remove the InputManager script from the _GameManager object.
    3) Drag the UFPS\Content\Prefabs\Players\SimplePlayer prefab into the scene.
    4) In the UFPS code file UFPS\Base\Scripts\Gameplay\Combat\vp_HitscanBullet.cs, paste the following code at line 150:
    Code (CSharp):
    1. // Check for Destructible objects.
    2. DestroyIt.Destructible destObj = m_Hit.collider.gameObject.GetComponentInParent<DestroyIt.Destructible>();
    3. if (destObj != null)
    4.     destObj.ApplyDamage(20); //do 20 points of damage per bullet hit
    5) Run the scene. When you shoot a destructible object, each bullet will do 20 points of damage, which you can adjust for your game.

    Hopefully that helps you get started.
     
    Last edited: May 14, 2016
    Theekshana-A likes this.
  35. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    DestroyIt 1.4.1 is now available on the Unity Asset Store.

    Changelog:
    • Added: TagItStub script so you can make DestroyIt-Ready assets that use TagIt scripts.
    • Added: New option on Destructible script "Ignore Collisions Under [X] Magnitude", which is useful for things like destructible tires, which should ignore most small-to-medium collisions yet still take full damage from bullets.
    • Fixed: Particle systems will no longer have DamageMaterial scripts added to them at runtime. This was a bug introduced by adding SkinnedMeshRenderer support.
    • Sink Into Ground option on Destructible script is now only available if the Destructible object has a rigidbody.
    • Bullets and the Axe melee weapon will now ignore trigger colliders.
    • The Axe melee weapon will now ignore the CharacterController tagged as "Player". This will prevent the player from hitting himself with the Axe.
    • Object Pool importing and saving improved. You can now import/save object pool files to different locations. When importing a file, it will now update existing objects in the pool instead of replacing all objects. Also added a Clear button to quickly remove all objects from the pool.
     
  36. Theekshana-A

    Theekshana-A

    Joined:
    Sep 27, 2014
    Posts:
    81
    Is there a way to make a prefab drop on destruction?
     
  37. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    Can you explain what you mean by that?
     
  38. Theekshana-A

    Theekshana-A

    Joined:
    Sep 27, 2014
    Posts:
    81
    Like when a destructible object gets destroyed. It would drop something like a item in the format of a prefab.
     
  39. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    That's primarily what DestroyIt does. Have you looked at the documentation, the videos on our Youtube channel, or the demo scenes available in the package?
     
  40. Theekshana-A

    Theekshana-A

    Joined:
    Sep 27, 2014
    Posts:
    81
    I am overseas right now with 200kb/s internet so yeah I will take a look when I get home
     
  41. Blackghost

    Blackghost

    Joined:
    Oct 2, 2012
    Posts:
    111
    Is this easy to integrate into a third person asset?
     
  42. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi, Blackghost,

    Are you talking about a third person controller asset? If so, then yes, DestroyIt can be integrated with that. We provide a simple first person controller with weapons in our web demo so customers can try out the destruction and get a feel for how our asset works. But the controller isn't meant to be production-ready. Our focus is on destruction, we assume most people will want to integrate DestroyIt with a high-quality controller asset.

    So far, we've had good results integrating DestroyIt with UFPS, the turret controller from the Sci-Fi Effects pack, and Edy's Vehicle Physics. DestroyIt will work with many more assets, those are just the third-party controllers we've personally tried.
     
  43. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Hi there, just got the asset and it's really nice! Great work.

    I had a question about destroyed objects. Is there any sort of message or event I can subscribe to so that my script on a destroyed object will be notified when it is destroyed? Besides the unity OnDestroy function as that is called whenever the scene is closed.
     
  44. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi capitalJmedia,

    DestroyIt doesn't currently have any events that fire when Destructible objects are destroyed, but that's a great idea, so we went ahead and added that feature.

    There's now a DestroyedEvent on all Destructible objects that any listener can subscribe to. We also added a small script called WhenDestroyed that you can drag onto any Destructible object and it will log to the console when the object is destroyed, along with that object's name and location (to illustrate how to use additional data if needed).

    WhenDestroyed script:
    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3.  
    4. namespace DestroyIt
    5. {
    6.     /// <summary>
    7.     /// This is a helper script that listens to a Destructible object's DestroyedEvent and runs additional code when the object is destroyed.
    8.     /// Put this script on a GameObject that has the Destructible script.
    9.     /// </summary>
    10.     public class WhenDestroyed : MonoBehaviour
    11.     {
    12.         private Destructible destObj;
    13.  
    14.         private void Start()
    15.         {
    16.             // Try to get the Destructible script on the object. If found, attach the OnDestroyed event listener to the DestroyedEvent.
    17.             destObj = gameObject.GetComponent<Destructible>();
    18.             if (destObj != null)
    19.                 destObj.DestroyedEvent += OnDestroyed;
    20.         }
    21.  
    22.         private void OnDisable()
    23.         {
    24.             // Unregister the event listener when disabled/destroyed. Very important to prevent memory leaks due to orphaned event listeners!
    25.             destObj.DestroyedEvent -= OnDestroyed;
    26.         }
    27.  
    28.         /// <summary>When the Destructible object is destroyed, the code in this method will run.</summary>
    29.         private void OnDestroyed()
    30.         {
    31.             Debug.Log(String.Format("{0} was destroyed at world coordinates: {1}", destObj.name,
    32.                 destObj.transform.position));
    33.         }
    34.     }
    35. }

    WhenDestroyed script in action:


    This feature will be included in the upcoming DestroyIt 1.4.3 release (no ETA yet), but if you need this functionality now, please send your invoice number to support@modelshark.com and we will make the pre-release version available to you.
     
    Last edited: Sep 18, 2017
  45. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Awesome, thank you very much.
     
  46. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    One question about the progressive damage materials. How do I use that feature? I can't tell from the manual or the example scene.
     
  47. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    On your undamaged model's material, put a damage material like ProgDamageCracks1 on the secondary map's Albedo and ProgDamageCracks1_NM on the Normal map there. That's what your model will look like when it's fully damaged.

    Then put DetailMask1_D0 on the Detail Mask of that material. As you damage your model, it'll replace DetailMask1_D0 with DetailMask1_D1, then DetailMask1_D2, etc, showing more damage. Look at \Assets\DestroyIt - Core\Resources\Material_Preload\Mahogany-DamageLevel-PBR for an example.

    Make sure the materials are in a Resources\Material_Preload folder.
     
  48. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi everyone,

    We've had a few customers ask about integrating DestroyIt with UFPS, since UFPS has changed a lot since 2014, when we did our video.

    So here are updated step-by-step instructions for how to integrate DestroyIt with UFPS melee damage and hitscan bullets. Both of these instructions were created using UFPS 1.6 (the current latest version).

    UFPS MELEE DAMAGE

    1) Start a new project.
    2) Import DestroyIt and UFPS.
    3) Open the DestroyIt demo scene.
    4) Delete the First Person Controller from the scene.
    5) On the _GameManager object, delete the InputManager script.
    6) Drag the \Assets\UFPS\Base\Content\Prefabs\Players\Hero prefab into the scene.
    7) Drag the \Assets\UFPS\Base\Content\Prefabs\Pickups\Weapons\PickupMace prefab into scene.
    8) In a text editor, open \Assets\UFPS\Base\Scripts\Gameplay\Player\Local\vp_FPWeaponMeleeAttack.cs and insert the following code at line 300:
    Code (CSharp):
    1. DestroyIt.Destructible destObj = hit.collider.GetComponentInParent<DestroyIt.Destructible>();
    2. if (destObj != null)
    3.     destObj.ApplyDamage(20);

    9) Run the scene, pick up the mace. Now you can smash any of the destructible objects in the scene and it will do 20 hit points of damage on each hit (change the damage as you see fit).

    UFPS HITSCAN BULLET DAMAGE

    *** Follow steps 1 through 6 above for Melee Damage. ***
    7) Drag the \Assets\UFPS\Base\Content\Prefabs\Pickups\Weapons\PickupPistol prefab into scene.
    8) In a text editor, open \Assets\UFPS\Base\Scripts\Gameplay\Combat\vp_Bullet.cs and insert the following code at line 170:
    Code (CSharp):
    1.  
    2. // Check for Destructible objects.
    3.         DestroyIt.Destructible destObj = m_Hit.collider.gameObject.GetComponentInParent<DestroyIt.Destructible>();
    4.         if (destObj != null)
    5.             destObj.ApplyDamage(20); //do 20 points of damage per bullet hit
    6.  


    9) Run the scene, pick up the pistol. Now you can shoot any of the destructible objects in the scene and it will do 20 hit points of damage on each hit (change the damage as you see fit).
     
    Last edited: Sep 18, 2017
  49. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    479
  50. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi Frpmta,

    I don't have experience with either of those assets, but from reading the descriptions I don't see why it wouldn't work. DestroyIt is pure realtime collider- and rigidbody-based physics, so if those tools can record physics interactions and replay them as animations, it seems like it would work fine. You might want to check with the creators of those tools just to confirm that they work as you're expecting.