Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

[Released] DestroyIt - Cinematic Destruction System

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

  1. Frpmta

    Frpmta

    Joined:
    Nov 30, 2013
    Posts:
    461
    Oh, I was asking if DestroyIt could do it because because normally anything that allows a simulation allows baking it :D
     
  2. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    No, DestroyIt doesn't record physics or bake animations.

    The focus of DestroyIt is high-performance, high-quality, real-time object destruction. Also included with DestroyIt are many features that support that type of destruction, such as: progressive damage, triggering particle effects at specific damage levels, clinging debris, managed debris culling, automatic object pooling, re-parenting debris, and much more.
     
  3. siblingrivalry

    siblingrivalry

    Joined:
    Nov 25, 2014
    Posts:
    384
    Hi,

    hope this question makes sense :)

    I want different weapons to cause different types of damage.

    So shooting a brickwall can make partial damage to the wall, but hitting with a melee sledgehammer can destroy the wall completely.

    Similarly with my wooden wall pefabs. If you shoot a woiden wall it will chip away so that it no longer provides defensive cover, but will not be completely destroyed. Hitting that wall with an axe will destroy it completely.

    Many thanks
     
  4. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    Hi siblingrivalry,

    This can be accomplished using the tagging system in DestroyIt. Essentially, what you would do is tag your colliders with whatever materials they represent (wood, concrete, cloth, etc) and then modify the weapons so they do variable damage based on what type of material they hit.

    I coded up an example of how to do this with the melee weapon (the axe). First, I copied the brick wall from the demo scene and replaced the brick texture with a wooden one. Then I tagged the collider on the brick wall as "Concrete" and the wooden wall as "Wood", using the TagIt script. (Note: the script needs to be placed on the same gameobject as your collider)

    Then I changed the melee weapon's code to look for the tag when it hits a collider. Note that this same process will work for any of the weapons - they all hit colliders and then do damage to the Destructible parents. In this case, I gave the axe a -20 damage penalty against Concrete, and +70 damage against wood.

    InputManger.cs, DoMeleeDamage() method:
    Code (CSharp):
    1. // Apply damage if object hit was Destructible
    2. Destructible destObj = col.gameObject.GetComponentInParent<Destructible>();
    3. if (destObj != null)
    4. {
    5.     // Check what type of object was hit and adjust the damage accordingly.
    6.     int adjustedMeleeDamage = meleeDamage;
    7.     if (tagIt != null && tagIt.tags.Count > 0)
    8.     {
    9.         if (tagIt.tags.Contains(Tag.Wood)) // If axe hits wood, give it a +70 damage bonus.
    10.         {
    11.             adjustedMeleeDamage += 70;
    12.             Debug.Log("Bonus: Axe +70 damage to Wood. Total Damage: " + adjustedMeleeDamage);
    13.         }
    14.         if (tagIt.tags.Contains(Tag.Concrete)) // If axe hits concrete, give it a -20 damage penalty.
    15.         {
    16.             adjustedMeleeDamage -= 20;
    17.             Debug.Log("Penalty: Axe -20 damage to Concrete. Total Damage: " + adjustedMeleeDamage);
    18.         }
    19.     }
    20.     ImpactInfo meleeImpact = new ImpactInfo() { Damage = adjustedMeleeDamage, AdditionalForce = 150f, AdditionalForcePosition = firstPersonController.position, AdditionalForceRadius = 2f };
    21.     destObj.ApplyImpactDamage(meleeImpact);
    22. }
    And here are the results. The concrete object takes about 8 hits from the axe to destroy, and the wooden wall is immediately destroyed, even though they both start out with 100 hit points:

     
    Last edited: Sep 18, 2017
  5. siblingrivalry

    siblingrivalry

    Joined:
    Nov 25, 2014
    Posts:
    384
    Fantastic. Many thanks
     
  6. siblingrivalry

    siblingrivalry

    Joined:
    Nov 25, 2014
    Posts:
    384
  7. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    173
    Thanks for bringing that to our attention. It's been fixed now.
     
  8. siblingrivalry

    siblingrivalry

    Joined:
    Nov 25, 2014
    Posts:
    384
    No worries.

    Would destroy It work ok with playmaker? Cant see why there would be any issues, but thought would be worth asking.
     
  9. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    Yes, DestroyIt will work with Playmaker. Here's a simple custom Playmaker Action I created that deals a configurable amount of damage to the Destructible object assigned to it:
    Code (CSharp):
    1. using HutongGames.PlayMaker;
    2.  
    3. namespace DestroyIt
    4. {
    5.     [ActionCategory(ActionCategory.GameObject)]
    6.     [Tooltip("Causes damage to a Destructible object.")]
    7.     public class DamageObject : FsmStateAction
    8.     {
    9.         [Tooltip("The Destructible object to cause damage to.")]
    10.         public FsmGameObject destructibleObject;
    11.         [Tooltip("The amount of damage to cause.")]
    12.         public FsmInt damage;
    13.  
    14.         public override void Reset()
    15.         {
    16.             destructibleObject = null;
    17.             damage = 0;
    18.         }
    19.  
    20.         public override void OnEnter()
    21.         {
    22.             if (destructibleObject == null) return;
    23.  
    24.             // Find the first available Destructible object.
    25.             Destructible dest = destructibleObject.Value.GetComponentInChildren<Destructible>();
    26.             if (dest == null) return;
    27.  
    28.             dest.ApplyDamage(damage.Value);
    29.         }
    30.     }
    31. }
    Note: I don't actually know Playmaker, so there are probably much better ways to create your custom actions. I just followed a beginner tutorial I found on the Hutong Games site. But if you do know Playmaker, you would probably find it easy to add custom actions for DestroyIt. The code for DestroyIt is very open to being extended or modified to your needs.

    Here's a video of the above code in action. I have my Playmaker FSM configured so when I press the Tab key, it deals damage to the destructible column object. In the video, I press Tab three times, and each time it does 20 points of damage to the object and the third time destroys it.

     
    Last edited: Jun 24, 2016
    antoripa likes this.
  10. siblingrivalry

    siblingrivalry

    Joined:
    Nov 25, 2014
    Posts:
    384
    Great thanks.
     
  11. VirtualDawn

    VirtualDawn

    Joined:
    Sep 15, 2014
    Posts:
    13
    Hey zangad! I'm considering buying DestroyIt, but since I'm working with virtual reality, I have some questions:
    How much does this use shaders for the effects? We're using the free Lab Renderer(for VR) by Valve, but it does'nt really work with any other shaders than their own.
    So, how does this perform without custom shaders? Is it difficult to modify your shaders to work with valve lab renderer?

    Have you tried the performance of this package in vr?
     
  12. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    Hi DeanSledgehammer,

    We haven't personally tried DestroyIt with VR, but one of our customers recently released a VR game on Steam that uses DestroyIt and mentioned that performance was great.
    http://store.steampowered.com/app/468740

    In Unity 4, we used to use custom shaders to achieve the progressive damage effect (visual damage spread over the object as it takes more and more damage), but since moving to Unity 5, DestroyIt only uses the Standard Shader.

    To get progressive damage with the Standard Shader, we provide cracked/scratched/dented images that go in the Secondary Maps, and control the level of damage with a series of progressively-spreading Detail Mask images that are swapped out as the object takes more damage. When the object is destroyed, the materials (along with their secondary maps and detail masks) are transferred to the destroyed prefab or particle effect.

    If you won't be using progressive damage in your game, then any shader should work fine. You just wouldn't have a visual indicator of damage on the object until it was destroyed.
     
    Flurgle likes this.
  13. VirtualDawn

    VirtualDawn

    Joined:
    Sep 15, 2014
    Posts:
    13
    Alright, thanks a lot!
    You should consider rewriting the shaders for Lab Renderer materials. This seems to be the only good looking viable destruction package in unity(though I haven't tried it yet), so having a lab renderer/valve support (and maybe some vr optimizations if there are some) would be great selling point in the near future.

    I think your package will work well for us, I'll update here as we get further in the project, I think it's gonna be interesting footage.
     
  14. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    368
    Hello there. How easy is it to destroy a skinned character or object? If it isn't possible:
    1) When would this feature be available?
    2) What would the performance implications be?
     
  15. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    173
    Skinned mesh renderer destruction is already in DestroyIt, but we don't recommend using it for organic objects like characters. You could use DestroyIt to destroy a character, but only if you destroyed the entire character at once. You couldn't blow off an arm, for example, because the mesh is all one piece.
     
    Flurgle likes this.
  16. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    368
    @DeadlyAccurate that's a wonderful answer thanks. Blowing up a piece of a skinned mesh (not just a character) would help doing certain cinematic scenes. Is that something on the road map or even possible?
     
  17. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    173
    I'm not sure I understand the question. Are you asking if it's possible to destroy skinned mesh renderers? If so, yes, that feature is already in DestroyIt. Or are you asking if we plan to implement character destruction? We don't have any plans to implement character destruction at this time.
     
  18. siblingrivalry

    siblingrivalry

    Joined:
    Nov 25, 2014
    Posts:
    384
    Hi guys,

    Looking at the chip away videos. Looks great.

    Can different assets be dropped as resources based on the tools used? I assume it would be using tags as you previously instructed for damage.

    if hitting a wall with an axe, when it chips away it drops bricks, but if it is attacked with explosives or guns then it will just be destroyed leaving no resources to loot.

    thanks
     
  19. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    Yes, the process would be the same as doing variable damage to an object based on the type of weapon.

    You could do this two ways that I can think of. The first way is like above, where the check is on the weapon to see what you've hit. On the axe for example, with each hit against a brick wall, it could spawn in a brick GameObject that falls to the ground and can be picked up by the player.

    The second way to do it would be putting the checks on the destructible object, not the weapon. This way would require extra checks, but might be a more robust solution for a deeper game (like a survival sandbox). Each time a destructible object is hit, in its ApplyDamage method, it examines the type of weapon that hit it, and the amount of damage that was applied. If the destructible object is a brick wall and the type of weapon that damaged it was an Axe, and the damage was more than 20 points, then for every 20 points a brick GameObject would spawn in and fall to the ground. This would require tagging both the destructible objects and the weapons, as well as modifying the ApplyDamage() method to accept a weapon type parameter.

    That would probably be overkill for a simple game, but such a change would allow you to have players with high Strength or an Epic Axe for example, that could do 60 points of damage and drop 3 bricks per hit, or even use an area of effect weapon like a grenade that drops a lower amount of resources on multiple objects in the splash damage area.

    Hope that helps!
     
  20. VirtualDawn

    VirtualDawn

    Joined:
    Sep 15, 2014
    Posts:
    13
    Check out our trailer for Outrageous Grounds: The Maze.


    We're using DestroyIt for the destruction and it feels really nice in VR, bashing through walls with your fists, etc :D
    Thanks!
     
    MarcusWatson and julianr like this.
  21. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    173
    Awesome! That looks really cool, and I'm glad DestroyIt was able to be a help to you.
     
  22. funnyman6685

    funnyman6685

    Joined:
    Jul 5, 2014
    Posts:
    4
    Hello,

    I am trying to apply damaged to an object with a custom bat prefab in VR and I need it to apply damaged when the bat hits the object. How would I go about doing this?
     
  23. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    Hi funnyman,

    Without knowing what you've tried or the details of your custom bat prefab or character controller setup, I can only provide general tips/ideas:

    Any object with a collider and rigidbody on it will damage a Destructible object automatically if it hits with enough momentum and mass. Unfortunately, with most character controller setups, you can't just add a rigidbody to the weapons because character movements/attacks are handled with animations, not physics. If you add a rigidbody to the weapon, when you run the scene it will just fall to the ground because it's not connected to any other physics-based bodies.

    So what we did for the Fireman's Axe in our demo scene is put an invisible floating point in the air in front of the character that acts as the "melee damage area". When the Mouse1 button is clicked, the axe animation plays, and at the end of it, a small-radius SphereCast checks for rigidbodies within the melee damage area and applies damage to all Destructible objects it hits. It also blasts the area with a small force explosion, which sends rigidbodies and debris flying. This approach fakes the impact, but it's what a lot of games do because it performs very well and you can use your cool attack animations.

    Even UFPS uses this type of hit system for melee weapons. The knife attack, for example, is simply a raycast out from the center of the character controller along the camera angle. If the raycast hits something, then it applies knife damage and force at the hit vector. This gives you a more accurate strike than a spherecast, but still involves no physics simulation.

    To apply the more accurate raycast-style strike to your bat, you would just need to raycast out from the hand bone to the end of the bat on every frame as it swings. In fact, if you are using UFPS, we've already created a video that shows how to do melee damage to destructible objects. The video is a little old, but the information is still relevant:



    I hope that helps. Please let us know if you run into issues.
     
  24. funnyman6685

    funnyman6685

    Joined:
    Jul 5, 2014
    Posts:
    4
    Thanks for the help, What I tried was just add a rigidbody and collider to the bat model and that seem like it worked but did not know if it needed to add damaged to the object when it collided with a script. There is no animation of the swing of the bat just mounts where the Vive controller is and you swing the controller and swings the bat in the game. Thanks again for your help.
     
  25. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    Ah, ok, that makes sense. In that case, then yes, you are using a physics-based bat with rigidbody and collider, so you shouldn't need to add any additional scripts, it should automatically damage Destructible objects. You may need to tweak the mass settings on your bat rigidbody (or destructible objects it hits) to get the desired amount of damage with each hit.
     
  26. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    337
    Does this allow cut a tree in any angle by a weapon?
     
  27. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    Hi dienat,

    No, what you're looking for is a mesh-cutting system. DestroyIt is a prefab-replacement system, meaning when an object is destroyed, it is replaced with a destroyed prefab version.

    There are several mesh cutting systems on the asset store. You might take a look at this one to see if it would fit your needs, it slices a mesh based on a plane:
    https://www.assetstore.unity3d.com/en/#!/content/59618

    (Note: we have no affiliation with the Mesh Slicer asset or developers.)
     
  28. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    337
    Thanks for the info
     
  29. antoripa

    antoripa

    Joined:
    Oct 19, 2015
    Posts:
    1,162
    Hi,
    we are planning to use DestroyIT in a new project.
    I would know if and how we can create new PBR material or how we can tranform that material like the one for progressive destrunction effect. Thanks
     
  30. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    173
    Do you mean your own shader? DestroyIt currently uses the Unity Standard shader, so it supports PBR. The destruction effect is added to the Secondary Maps, with the Detail Mask used to control the layers of progression.
     
    antoripa likes this.
  31. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    Antoripa,

    Just to elaborate on DeadlyAccurate's answer, here is an excerpt from our previous post about using progressive damage with Unity 5 Standard PBR shaders:

    "In Unity 5, we simplified [progressive damage] by using the Secondary textures and detail mask already built into the Standard shader. This means you won't need to use any special shaders to get progressive damage, just the Standard one. This gives you MUCH more flexibility. Now if you need high reflection, you just add a reflection or metallic map. If you need transparency, you simply lower the alpha of your albedo color. If you need emission (something we didn't even cover with our previous shaders) you simply add an emission map. The drawback is that progressive damage uses the Secondary texture slots. But we feel the pros far outweigh that drawback. And besides, you could always combine the textures you were going to use in the Secondary slots to your albedo if you really needed to."

    Here's a visual of how progressive damage works with the Standard shader:

     
    Last edited: Sep 18, 2017
    GMax and antoripa like this.
  32. antoripa

    antoripa

    Joined:
    Oct 19, 2015
    Posts:
    1,162
    Hi,
    best support from Asset Store vendor. That's really important. Thanks a lot for the detailed asnwer.
    I am going to use that tool in a new brand project as ThIird Person Shooter Game
    I will do some test in the next few days following the above explanation.
    A.
     
    Setmaster and GMax like this.
  33. zangad

    zangad

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

    One of our customers asked if DestroyIt would work with Substances (procedurally-generated materials by Allegorithmic) for progressive damage materials. The answer is yes! We're huge fans of Substance ourselves, so we thought we'd share how to create a progressive damage material using a substance with DestroyIt.

    Step-by-Step:
    1) Duplicate one of the materials in the Material Preload folder (any material will do).
    2) Make sure your substance is not in the Material Preload folder. Only Unity5 Standard Shader materials should be there.
    3) Drag the texture outputs from your substance to your new material, matching diffuse to diffuse, normal to normal, etc.
    4) Assign your new material to a Destructible object.

    That's it! As your destructible object takes damage, the new substance material will show progressive damage just like any other material.

    Image Illustration:

     
    Last edited: Sep 18, 2017
    GMax likes this.
  34. HellPatrol

    HellPatrol

    Joined:
    Jun 29, 2014
    Posts:
    38
    zangad likes this.
  35. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    Hi HellPatrol,

    Thanks for the question. I'm fairly confident they will work well together, but we've reached out to Inv3ctor (the asset developer) to request a copy of their asset so we can test and confirm compatibility. We'll let you know as soon as we find out.
     
    HellPatrol likes this.
  36. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    I got a chance to try out Invector's Third Person Controller - Melee Combat asset with DestroyIt. The two work well together as long as you setup your colliders as the controller expects. The HitBox script on the controller's hands and feet check colliders they hit for certain scripts, in order to know what to do with them. You can add the scripts/tags/layers manually if you prefer, but we've created some helper scripts to make that process easy and automated for you.

    Simply drag the vDestructible script (below) onto your DestroyIt Destructible objects, and at runtime it will add the required scripts, and tag all child colliders appropriately and put them into the correct layer. Below are the two scripts, as well as a Unity package for convenience:

    vDestructible:
    Code (CSharp):
    1. using DestroyIt;
    2. using UnityEngine;
    3.  
    4. // This script provides an easy way to setup ModelShark Studio's Destructible objects
    5. // to work with Invector's Third Person Controller Melee Combat Template.
    6.  
    7. // Place this script on your Destructible object, at the same level as the Destructible
    8. // script.
    9.  
    10. [RequireComponent(typeof(Destructible))]
    11. public class vDestructible : MonoBehaviour
    12. {
    13.     public float forceMultiplier = 0.5f;
    14.     public GameObject defaultHitEffect;
    15.  
    16.     void Awake()
    17.     {
    18.         Destructible destructible = GetComponent<Destructible>();
    19.         Collider[] colliders = destructible.GetComponentsInChildren<Collider>();
    20.         for (int i=0; i<colliders.Length; i++)
    21.         {
    22.             if (!colliders[i].isTrigger) // Ignore trigger colliders
    23.             {
    24.                 // Add the DestructibleCollider script to each collider and configure it.
    25.                 vDestructibleCollider dc = colliders[i].gameObject.GetComponent<vDestructibleCollider>();
    26.                 if (dc == null)
    27.                     dc = colliders[i].gameObject.AddComponent<vDestructibleCollider>();
    28.  
    29.                 dc.ForceMultiplier = forceMultiplier;
    30.  
    31.                 // If a Default Hit Effect was specified, add the HitDamageParticle script to each collider.
    32.                 if (defaultHitEffect != null)
    33.                 {
    34.                     vHitDamageParticle hdp = colliders[i].gameObject.GetComponent<vHitDamageParticle>();
    35.                     if (hdp == null)
    36.                         hdp = colliders[i].gameObject.AddComponent<vHitDamageParticle>();
    37.  
    38.                     hdp.defaultHitEffect = defaultHitEffect;
    39.  
    40.                     // In order for hit effects to play, each collider also needs to have a vCharacter script.
    41.                     vCharacterStandalone character = colliders[i].gameObject.GetComponent<vCharacterStandalone>();
    42.                     if (character == null)
    43.                         colliders[i].gameObject.AddComponent<vCharacterStandalone>();
    44.                 }
    45.             }
    46.         }
    47.     }
    48. }
    49.  
    vDestructibleCollider:
    Code (CSharp):
    1. using DestroyIt;
    2. using Invector.EventSystems;
    3. using UnityEngine;
    4.  
    5. // This script provides an easy way to setup ModelShark Studio's Destructible objects
    6. // to work with Invector's Third Person Controller Melee Combat Template.
    7.  
    8. // This script is automatically added to each collider when the vDestructible script is
    9. // on your Destructible object.
    10.  
    11. [RequireComponent(typeof(Collider))]
    12. public class vDestructibleCollider : MonoBehaviour, vIDamageReceiver
    13. {
    14.     public float ForceMultiplier { get; set; }
    15.     private Rigidbody rbody;
    16.     private Destructible destructible;
    17.  
    18.     void Awake()
    19.     {
    20.         destructible = GetComponentInParent<Destructible>();
    21.         rbody = GetComponentInParent<Rigidbody>();
    22.  
    23.         // Tag this collider with "Interactable" so it can be attacked.
    24.         if (tag != "Interactable")
    25.             tag = "Interactable";
    26.  
    27.         // Add this collider to the "Enemy" layer so the character controller will not recoil when hitting it.
    28.         if (gameObject.layer != LayerMask.NameToLayer("Enemy"))
    29.             gameObject.layer = LayerMask.NameToLayer("Enemy");
    30.     }
    31.  
    32.     public void TakeDamage(Damage damage, bool hitReaction = false)
    33.     {
    34.         if (ForceMultiplier <= 0f) // Default to 0.5f if for some reason ForceMultiplier hasn't been set.
    35.             ForceMultiplier = 0.5f;
    36.  
    37.         var point = damage.hitPosition;
    38.         var relativePoint = transform.position;
    39.         relativePoint.y = point.y;
    40.         var forceForward = relativePoint - point;
    41.  
    42.         if (rbody != null && destructible != null)
    43.         {
    44.             Debug.Log("[" + destructible.name + "] got hit for " + damage.value + " points of damage!");
    45.             destructible.ApplyDamage(damage.value);
    46.             rbody.AddForce(forceForward * (damage.value * ForceMultiplier), ForceMode.Impulse);
    47.         }
    48.     }
    49. }
    50.  
    Unity Package (Includes the two scripts above):
    DestroyIt Scripts for Invector TPC Melee Combat.unitypackage

    I've also put together a quick video of the process, with some explanations of what the scripts do:
     
    Last edited: Mar 19, 2017
    HellPatrol, GMax and Invector like this.
  37. Invector

    Invector

    Joined:
    Jun 23, 2015
    Posts:
    887
    Combine Ragdoll + Destruction = Lots of Fun! :p
     
  38. HellPatrol

    HellPatrol

    Joined:
    Jun 29, 2014
    Posts:
    38
    Wow, that's just great.
    Thanks for your work, I buy it then
     
  39. HellPatrol

    HellPatrol

    Joined:
    Jun 29, 2014
    Posts:
    38
    Works as promised :)

    But its kinda useless because you can just walk through an DestroyIt object - it destroys it immediately
     
  40. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    The reason it does this is because the Invector Third Person Controller has a rigidbody with a mass of 50. Most character controllers don't have a separate rigidbody. Since this one does, it collides with and applies force to objects. I can't speak for Invector, but from what I can tell that's by design.

    DestroyIt Destructible objects are designed to automatically take damage from collisions with other rigidbodies, even if those objects are not themselves destructible objects (for instance, a cannonball or a rigidbody bullet).

    So, if the mass of a destructible object is far less than the mass of the character controller, then it will be highly damaged or destroyed from collisions with the controller. Essentially, the character controller is a fast-moving wrecking ball.

    If you don't want this behavior, you have several options:
    • Reduce the mass of the character controller's rigidbody.
    • Increase the mass of your Destructible objects' ridigbodies.
    • On your Destructible objects, on the Destructible script, where it says "Ignore collisions under [2] magnitude", change that number to 20.
    • On the Destructible script, comment out the entire OnCollisionEnter method. That will make all Destructible objects ignore collisions with other rigidbodies.
     
  41. HellPatrol

    HellPatrol

    Joined:
    Jun 29, 2014
    Posts:
    38
    Thats exactly what i wanted !
     
  42. ParadoxSolutions

    ParadoxSolutions

    Joined:
    Jul 27, 2015
    Posts:
    272
    Hello, I saw a post on how to setup the UFPS hitscan bullets with DestroyIt but since that has been depreciated (but kept for backwards compatability) and vp_FXBullet is the new bullet script. I just purchased destroyit and was wondering if this has came up before. (note UFPS now spawns impact effects will this interfere with destroyit impact effects?) How should I set this up?
     
  43. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    Hi FirefightGI,

    Thanks for reaching out to us. I checked out the new UFPS features you mentioned. While it looks like they've added a lot of new goodies, the core of the system works much the same as it did when I made my older posts/videos. For example, vp_FXBullet actually inherits from vp_Bullet, which is a standard Raycast Hit system, like we use in our demo scene. A lot of things have moved around in the vp_Bullet code, and I notice it now favors message broadcasting to handle hit processing, but if you keep following the flow, you eventually find a method TryDamage(), and that's where you can attach additional code to check for Destructible objects.

    And no, there's no interference with DestroyIt's impact hit effects. The two systems will work well together, you just have to decide which parts you want to use from each system. For instance, if you want to use UFPS's hit effects and bullet decals on DestroyIt objects, then just put a vp_Surface_Identifier script on the Destructible object, identify it as wood/metal/etc, and it works. If you would rather use DestroyIt's impact hit effects on DestroyIt objects, then you can copy that feature from DestroyIt's InputManager and wire it to UFPS's vp_Bullet code (see below).

    I wrote some code to illustrate how you can bridge the two frameworks to get what you want out of them. There are many ways to accomplish this, and it might be more elegant to create a custom DamageHandler for DestroyIt objects and pass that to UFPS, but I went with the easiest solution so you can drop the code into your project and get going. This code adds DestroyIt hit effects to DestroyIt objects inside UFPS scenes, but does not affect UFPS objects. It also allows DestroyIt objects to take damage from both UFPS bullets and UFPS explosions.

    Here's a quick video of the results:


    Here's step-by-step instructions:
    1) Import UFPS (first) and DestroyIt (second) into a new project.
    2) Open a UFPS demo scene (I chose UFPS_DemoScene3).
    3) Click Window => DestroyIt => Minimal Setup.
    4) Drag DestroyIt Destructible objects into your scene.
    5) Adjust the Hit Points of DestroyIt Destructible objects (most UFPS destructible objects have 1-2 hit points).
    6) Create a new empty game object, call it HitEffectManager. Attach the HitEffectManager script to it (below).
    7) Assign the hit effects on the HitEffectManager to DestroyIt hit effect prefabs (see below).
    8) Open the UFPS vp_Bullet script. Add the vp_Bullet code (below) to the TryDamage() method.
    9) Open the UFPS vp_Explosion script. Add the vp_Explosion code (below) to the DoExplode() method.

    HitEffectManager: (this allows you to reference hit effect prefabs without using DestroyIt's InputManager)

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class HitEffectManager : MonoBehaviour
    4. {
    5.     public GameObject strikeDirtPrefab;
    6.     public GameObject strikeConcretePrefab;
    7.     public GameObject strikeWoodPrefab;
    8.     public GameObject strikeGlassPrefab;
    9.     public GameObject strikeMetalPrefab;
    10.     public GameObject strikeRubberPrefab;
    11.     public GameObject strikeStuffingPrefab;
    12.  
    13.     private static HitEffectManager _instance;
    14.     private HitEffectManager() {} // Hide the default constructor.
    15.  
    16.     public static HitEffectManager Instance
    17.     {
    18.         // If instance of this singleton is null, try to get it from the scene.
    19.         get { return _instance ?? (_instance = FindObjectOfType<HitEffectManager>()); }
    20.     }
    21. }
    vp_Bullet Code: add to top of TryDamage() method

    Code (CSharp):
    1.  
    2. //HANDLE MODELSHARK DESTRUCTIBLE OBJECTS
    3. Destructible dest = m_Hit.collider.GetComponentInParent<Destructible>();
    4. if (dest != null)
    5. {
    6.     // If the object is a ModelShark Destructible, apply damage to it.
    7.     dest.ApplyDamage(Mathf.RoundToInt(Damage));
    8.  
    9.     // Check if bullet struck wood, concrete, glass, etc. by using the TagIt system.
    10.     TagIt tagIt = m_Hit.collider.GetComponent<TagIt>();
    11.     if (tagIt != null && tagIt.tags.Count > 0)
    12.     {
    13.         GameObject prefab;
    14.         if (tagIt.tags.Contains(Tag.Wood))
    15.             prefab = HitEffectManager.Instance.strikeWoodPrefab;
    16.         else if (tagIt.tags.Contains(Tag.Glass))
    17.             prefab = HitEffectManager.Instance.strikeGlassPrefab;
    18.         else if (tagIt.tags.Contains(Tag.Metal))
    19.             prefab = HitEffectManager.Instance.strikeMetalPrefab;
    20.         else if (tagIt.tags.Contains(Tag.Rubber))
    21.             prefab = HitEffectManager.Instance.strikeRubberPrefab;
    22.         else if (tagIt.tags.Contains(Tag.Stuffing))
    23.             prefab = HitEffectManager.Instance.strikeStuffingPrefab;
    24.         else // Default is concrete effect
    25.             prefab = HitEffectManager.Instance.strikeConcretePrefab;
    26.  
    27.         ObjectPool.Instance.Spawn(prefab, m_Hit.point, Quaternion.LookRotation(m_Hit.normal));
    28.     }
    29.     else // Default is concrete effect
    30.         ObjectPool.Instance.Spawn(HitEffectManager.Instance.strikeConcretePrefab, m_Hit.point, Quaternion.LookRotation(m_Hit.normal));
    31. }
    vp_Explosion Code: add just under "foreach (Collider hit in colliders)"
    Code (CSharp):
    1. // If the object is a ModelShark Destructible, apply damage to it.
    2. Destructible dest = hit.GetComponentInParent<Destructible>();
    3. if (dest != null)
    4.     dest.ApplyDamage(new ExplosiveDamage() { BlastForce = Force, Position = OriginalSource.position, Radius = Radius, UpwardModifier = UpForce });
     
    Last edited: Jul 6, 2018
  44. b4c5p4c3

    b4c5p4c3

    Joined:
    Jan 4, 2013
    Posts:
    537
    Love the UFPS integration
     
  45. keifyb

    keifyb

    Joined:
    Feb 12, 2016
    Posts:
    61
    remember to add

    using DestroyIt;

    at the top of vp_Bullet and vp_Explostion ;)
     
    Last edited: Dec 7, 2016
  46. keifyb

    keifyb

    Joined:
    Feb 12, 2016
    Posts:
    61
    would love these intergations added to the package. Also some photon scripts would be amazing help for ufps multiplayer please.
     
    Last edited: Dec 7, 2016
  47. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    196
    Hi keifyb,

    The problem with adding integrations to our package is keeping them updated whenever other asset developers modify or refactor their code. It creates a dependency on their asset that if we ignore, would cause our package to throw errors and upset customers.

    So the best we can do for now is provide information on how to integrate DestroyIt with other systems, based on the information we have at the time.
     
  48. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    173
    We will soon be submitting a new package for DestroyIt 1.5 to the Asset Store. Here is the changelog. This is a large update with many new features.

    1.5 (December 2016)


    We suggest that you delete your existing DestroyIt folder before importing the newer one, but please back up your project first!

    Major Changes:
    • Updated for Unity 5.5.
    • Progressive damage system overhauled to allow more control of damage levels and visible damage.
    • Damage can now be repaired, and any damage level effects will turn off as the object is repaired.
    • For each Destructible object, you can now have from 1 to 10 Damage Levels, and the hit point range can be customized for each.
    • All Destructible objects now start with 5 pre-defined Damage Levels.
    • Destructible objects now automatically detect if they are damaged or destroyed based on current hit points, rather than relying on external ApplyDamage() or ProcessDestruction() calls.
    • Performance increased by reducing Garbage Collection allocation on PlayDamageLevelEffects, HeadsUpDisplay, ReleaseClinging Debris, Bullet Update() method, Object Pool Spawn() method, and by removing the JointCleanup script.
    Minor Changes:
    • Damage masks extended from previously 5 levels of progressive damage to 10.
    • Many tooltips added to Destructible and DestructionManager script fields.
    • DestroyIt-Ready: You can now select a root folder in the Projects pane and click Convert Stubs to Destructible and it will find all prefabs under that folder.
    • DEMO SCENES
      • Removed unnecessary reflection probes and increased resolution of main reflection probe.
      • Bullet streak enhanced for a more visual, "tracer-like" effect.
      • Updated HUD UI to Unity Canvas.
      • ADDED: Performance, Keyboard/Mouse Controls, and Current Weapon sections to in-game HUD UI.
      • ADDED: Repair Wrench animated weapon with particle effect, to show off new Repair Damage feature.
      • DELETED: Some unused standard assets that were throwing warnings.
      • Changed to Linear lighting, tweaked tonemapping and blur camera settings, re-enabled light flares on SUV, changed reflection probes to baked lighting.
      • Removed "Draw Call Batching" scenario. Unity 5 now uses setpass calls and batches, making "draw calls" an inaccurate performance metric.
      • New cannon, repair wrench, and RPG models.
      • New brass pole, wall, longsword, and sconce models.
      • Mouse wheel can now be used to cycle through weapons.
      • Enhanced particle hit effects for metal, cloth, concrete, dirt, glass, and wood.
    • REMOVED: support for progressive damage on materials using legacy Unity 4 shaders.
    • REMOVED: Debug Monitor from Destructible script.
    • REMOVED: ForceCollisions script, it is no longer needed with Unity 5's physics.
    • REMOVED: unused progressive damage mask images.
    • Destructible custom editor script re-categorized, and fields moved to provide clarity.
    • Changed ApplyImpactDamage, ApplyExplosiveDamage, etc to ApplyDamage overload methods.
    • Refactored Damage types so they inherit from a generic Damage interface.
    • ADDED: Repaired event that fires when a Destructible object is repaired.
    • ADDED: Damaged event that fires when a Destructible object is Damaged.
    • ADDED: WhenDestroyedPlaySound.cs helper script for playing sounds when a destructible object is destroyed.
    • ADDED: WhenDamaged.cs helper script for taking action when a destructible object is damaged.
    • ADDED: WhenRepaired.cs helper script for taking action when a destructible object is repaired.

    Bug Fixes:

    • DestroyIt-Ready: Converting stubs/destructibles on Unsaved Scene caused undesired scene save popup.
    • DestroyIt-Ready: Converting a game object and its prefab at the same time caused duplicate scripts to be added.
    • Destructible objects can no longer be damaged into negative hit points.
    • When rotating a Destructible object with Damage Effects, the Damage Effects particles and gizmos did not rotate with the object.
     
  49. dienat

    dienat

    Joined:
    May 27, 2016
    Posts:
    337
    I see in your documentation you talk about trees can be destructed and show an axe hitting a tree, that means you can chop a tree bit a bit or just give one hit and the tree explodes or something like that?
     
  50. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    173
    Hi, dienat,

    We have an example in our demo here (#20) of a tree being chopped down. (You'll probably have to use Firefox to try the demo until we can get a webgl version available that will work in Chrome).

    In our demo, once the tree takes enough damage, it is replaced with the destroyed version, which consists of a stump and the rest of the tree. The stump stays in place, while the tree is allowed to react to physics.

    Most games don't chip away parts of the tree. Instead they use particle effects and damage decals to hint at on-going destruction, and then have the tree fall over or replace it with a destroyed version.

    As an example of games that do tree-chopping, here's 7 Days To Die -


    And here's tree-chopping in ARK: Survival Evolved (skip to 18:50 and again at 21:00) -


    In 7DTD, they use particle effects when the axe hits the tree and then have the undamaged tree lose kinematic on its rigidbody. In ARK, they use particle effects when the axe hits, a damage decal on the hit location, and then simply have the tree fade away. (Note: 7 Days To Die is made in Unity, but to the best of my knowledge doesn't use DestroyIt; ARK is made in the Unreal Engine).

    I hope that answers your question!