Search Unity

[Released] DestroyIt - Cinematic Destruction System

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

  1. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Here is a step-by-step guide to using DestroyIt with MFPS 2.0 (ver 1.9) for multiplayer destruction.

    1) Create a new Unity 3D project.
    2) Import MFPS 2.0: Multiplayer FPS (version 1.9).
    3) An installer window should pop up after MFPS 2.0 is imported. Click Install. Follow the prompts, install the suggested dependencies, and enter your AppId to setup Photo PUN Multiplayer.
    4) Open the \MFPS\Scenes\ExampleLevel scene.
    5) When prompted, import TextMeshPro's TMP Essentials. You don't need to import the TMP Examples & Extras.
    6) Import DestroyIt.
    7) With the MFPS ExampleLevel scene open, choose Window => DestroyIt => Setup - Minimal from Unity's top menu.
    8) From the \DestroyIt\Demos (safe to delete)\Prefabs\Destructible Objects\Pristine folder, drag the Column prefab into the ExampleLevel scene. Place it on the ground somewhere where you can shoot it.
    9) Select the Column game object in the Hierarchy and choose Add Component => Photon View.
    10) Choose Manual on the Observable Search on the Photon View component. Then drag the Column game object to the Observed Components field, and check the Position and Rotation checkboxes under the Synchronize Options on the Photon Transform View component.

    11) Open the \DestroyIt\Scripts\Behaviors\Destructible.cs script and add the [Photon.Pun.PunRPC] attribute to the ApplyDamage method.
    Add the [Photon.Pun.PunRPC] attribute to the Destructible.cs script here:

    12) Open the \MFPS\Scripts\Weapon\Projectiles\bl_Bullet.cs script and add the section of code below to the OnHit method.
    Add this code...
    Code (CSharp):
    1. DestroyIt.Destructible destObj = hit.collider.gameObject.GetComponentInParent<DestroyIt.Destructible>();
    2. if (destObj != null)
    3. {
    4.     Photon.Pun.PhotonView pv = destObj.GetComponent<Photon.Pun.PhotonView>();
    5.     pv.RPC("ApplyDamage", Photon.Pun.RpcTarget.All, bulletData.Damage);
    6. }
    ...to the OnHit() method in bl_Bullet.cs here:

    13) Save all your changes to the scripts and the ExampleLevel scene.
    14) Run the scene. You should be able to shoot the column and destroy it. Also, you can try using it for cover, and you'll notice that the enemy's bullets are also able to damage and destroy the column. Not a safe place to hide anymore! :)


    Multiplayer

    The instructions provided below are if you want to test multiplayer destruction in your scene with another developer.

    1) Each developer on your team will need MFPS 2.0 and DestroyIt and have them imported into their project as outlined in steps 1-6 above.
    2) Next, we'll export the integration changes we did in steps 7-13 above into a unitypackage so they don't have to go through those steps. In the Project window, use CTRL-click to select the ExampleLevel scene and the two scripts you modified. Right-click and choose Export Package. Uncheck Include Dependencies so only the modified files are included.
    3) Have your developer friend delete his/her ExampleLevel scene and import your unitypackage, so you are both running the same code at this point.
    4) Now run the scene, and have your friend also run the scene on their computer. Note that they will also need to use the same Photon AppId as you.
    5) From the in-game menu, create a new server and Join. Your friend should join the other (enemy) side. Now when either of you damage or destroy the destructible column with a bullet, you will each see progressive damage and the destroyed particle effect.



    From here, you could expand the destructible integration to knives, grenades, molotov cocktails, etc. You could also try using a more advanced destructible object that has damage effects like smoke or sparks, or one that leaves persistent debris from a destroyed prefab.

    In the case of persistent debris, you might want to make the debris pieces observable to Photon by adding Photon View components to each of them and syncing the position/rotation. Or you might decide that you like persistent debris but don't want to worry about syncing each piece with all clients to save network traffic. It really depends on if the position of each piece of debris is important to track in you game. For example, if flying debris can damage players, block movement (ie, a cave collapse), or provide cover, then you probably want to track its position/rotation for all clients.
     
    Last edited: Mar 18, 2022
  2. glangor

    glangor

    Joined:
    Mar 24, 2013
    Posts:
    15
    Thanks so much for your detailed reply, I realised I hadn't responded. I did look into those areas, much appreciated!
     
    zangad likes this.
  3. zangad

    zangad

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

    We have submitted a new version of DestroyIt (v1.15) to the Unity Asset Store. This new version works with Unity 2020 LTS and above, and is mainly focused around bug fixes and feature suggestions from customers. While we're waiting for the update to get approved, here are the patch notes and new feature highlights.

    New Features:
    * Feature: Added audio clip fields to the Destructible script, so it can play sounds when the object is damaged, repaired, or destroyed.
    * Feature: Added ability to scale Damage Effects prefabs on the Destructible script, much like how Fallback Particle Effect lets you override the scale on the Destructible script.
    * Feature: Added "Limit Damage" checkbox to Destructible script, so you can now specify Max and Min damage per hit, plus the minimum amount of time (in seconds) that must pass before the object can be damaged again. Really useful when you need rigidbody collisions to do a more predictable amount of damage.
    * Feature: Added a checkbox to DestructionManager that allows you to globally enable/disable damage to Destructible objects. This lets you turn on/off damage to destructible objects in one place.
    * Feature: Added Custom DestroyIt HDRP Lit shader and updated the DestroyIt User Guide on how to use it.
    * Feature: Fallback Particle Effects can now be set to Parent Under a transform. This is helpful for when you need the particle effect to follow along under a different game object.

    Minor Updates:
    * Updated: Code to work with Unity 2020.3.32f1 (LTS)
    * Re-centered the demo scenes so when they are opened for the first time (at world position 0,0,0) you see the scene correctly, instead of seeing a dark area with no terrain.
    * Removed the "DestroyIt-Ready" feature and removed the mentions of it in the User Guide PDF.
    * Added a ShockwaveSphere script, which is similar to the nuke's Shockwave Trigger Wall script, but this one moves out as a radius from the initial blast instead of as a wall.

    Bug Fixes:
    * Fixed: Damage Levels were not recalculating when totalHitPoints were modified at runtime through code. TotalHitPoints and CurrentHitPoints are now public properties with backing fields.
    * Fixed: DamageLevel hitpoint ranges are no longer cast to integers, which was causing an issue with destructible objects with very low hit points (ie, 5hp total with 5 damage levels) not progressing to the next damage level properly.
    * Fixed: Set ObjectPool container to inactive to prevent unwanted OnEnable events (such as destroyed sounds) when scene starts.
    * Fixed: ObjectPool no longer throws errors about "key already exists with that instance ID" when using nested prefab copies of Destructible objects.
    * Fixed: Moved the Particle Alpha (no fog) shader out of the "Demos (safe to delete)" folder, because the default particles use them and they are therefore required for the main DestroyIt asset. Now you can delete the Demos folder and not get pink textures on the default particle effects.
    * Fixed: Objects with DontDoDamage tag were doing damage to static destructible objects and destructible objects without rigidbodies.
    * Fixed: Issue with HitEffects where it was only playing the first effect found. Now plays all effects.
    * Fixed: Small issue with StructuralSupport script where it would only remove joints that had connected rigidbodies. Changed it so it removes all FixedJoints.

    New Feature Highlights:


    Audio Clips:
    You can now drag audio clips to the Destructible script and it will play the clip whenever the destructible object is destroyed, damaged, or repaired.

    (Check out Scenario #31 in the Main Scenarios Scene to try it out.)




    Damage Limits:
    You can now select Limit Damage on the Destructible script and specify the minimum and maximum damage done each time the object is damaged. This can be really useful for controlling how much damage rigidbody projectiles do to destructible objects, or for integrating DestroyIt with other assets that use a different health/hit point scale.

    You can also control how much time must pass before the object can be damaged again. This is useful when your destructible objects have complex colliders and might be hit multiple times by fast-moving rigidbodies (like a cannon ball). Normally, this would cause a lot of damage to the object, but now you can set it to only be damaged once per second for example, which would ignore the extra ricochet hits.

    (Check out Scenario #32 in the Main Scenarios Scene to try it out.)



    Enable/Disable Damage Globally:
    On the Destruction Manager, you can now turn on/off all damage to Destructible objects with one checkbox. This might be useful when you want to jump to a cut scene or important dialog in your game, and you don't want random damage and destruction to interfere. Or when you switch scenes, you may want to disable damage until the scene has fully loaded and open dialog windows have been resolved.



    Override Scale of Damage Effects:
    Much like how you can override the scale of the fallback particle effect, you can now override the scale of each Damage Effect on the Destructible script.



    Custom Shader Graph HDRP Lit Shader for Progressive Damage:
    As mentioned in this post, the custom HDRP shader we've been providing to customers on the forum is now included in the DestroyIt asset package.

    Enjoy! And if you run into any issues, please let us know.
     
    ledshok and EpicMcDude like this.
  4. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Dude yessss, this is looking like a great update! I was very happy to see an update notification for Destroyit. Thank you for supporting it!
     
    zangad likes this.
  5. tj_hooka

    tj_hooka

    Joined:
    Jul 4, 2019
    Posts:
    4
    Been having issues with trees, made a prefab(Using the palm_PRISTINE included in demo, health changed to 1) that I can place on terrain and can run into with a car, but the terrain tree versions don't react. I have tree collisions disabled on terrain but it just smacks to a stop without destroying the tree.

    Otherwise it's been interesting so far!
     
  6. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @tj_hooka,

    Hopefully we can help you get the vehicle damaging terrain trees. First, a couple of questions:

    1) Are you using a vehicle controller system asset? If so, which one? Each vehicle controller system does things a little differently. Some don't have rigidbodies on their vehicles. Does your vehicle have a collider and rigidbody on it? What is the mass of the vehicle's rigidbody? If you let me know which vehicle controller system you're using, I can try to reproduce it on my end (if we also own that system) and let you know what you need to modify to get things working with that system.

    2) Are the trees taking damage, but just not enough to destroy them? Or are they not taking any damage at all? If they are taking some damage, you may just need to adjust the mass of the vehicle so the impact has more collision magnitude. Or maybe adjust the hit points of the trees down a bit. The way you can find out if the tree is taking damage is to switch to scene view while the game is running, find the destructible tree stand-in (there should be an invisible collider around the tree that intercepts collisions) and check the Destructible script on the tree stand-in.

    Edit: Oh, one other easy way to check if your tree is taking any damage at all, is to enable the Limit Damage checkbox on the Destructible script and set the Minimum damage to something high, like 1000 hit points. This way, even if the tree is bumped and takes a point of damage, it will instead take 1000 damage and destroy the tree. If you set the Min damage to 1000 and it still doesn't destroy when you hit it with the vehicle, then it's not taking any damage, and I suspect that would be because your vehicle doesn't have a rigidbody, or the collider/rigidbody setup is configured differently. Regardless, it's good info to know for troubleshooting.
     
    Last edited: Apr 22, 2022
  7. tj_hooka

    tj_hooka

    Joined:
    Jul 4, 2019
    Posts:
    4
    Hey Zangad, Did try the minimum damage trick and setting HP of the tree to 1 but no such luck.

    1. Yes, have tried Edy's Vehicle Physics and another vehicle physics engine included in another asset. Will be trying rcc and nwh soonish. The prefabs I place work, but terrain trees don't. Colliders and Rigidbodies on the car, mass typically around 1000.

    2. There is collision but no damage. (Car stops instantly).

    I'll keep trying and probably throw a car into the destroyit demo with a terrain tree and smash some stuff to see if it's something to do with how I did the terrain.

    Using Unity 2020.3.33f1 and Universal RP.
     
    zangad likes this.
  8. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hey @tj_hooka,

    Thanks for the info. Since I also have Edy's Vehicle Physics, I took a look at reproducing the issue in our demo scene and found a few things that need to be tweaked to get cars destroying trees.

    I made a video of the changes, but it turned into more of a tech-focused troubleshooting discussion rather than a step-by-step. But I'll post both here in case you're curious about the troubleshooting stuff.

    Destructible Terrain Trees + Edy's Vehicle Physics (Step-By-Step)

    1)
    Import Edy's Vehicle Physics into your DestroyIt project (or vice-versa)
    2) Drag one of Edy's vehicle prefabs into the scene
    3) Drag Edy's Camera Controller prefab into the scene and point it to follow your vehicle's transform
    4) Delete DestroyIt's First Person Controller from the scene
    5) Delete DestroyIt's HUD from the scene
    6) Make a code change to line 242 in the TreeManager.cs script in the UpdateTrees() function so it doesn't strip off Rigidbodies from trees. Add this: && comp.GetType() != typeof(Rigidbody)
    7) Click the "Update Trees" button on the TreeManager component in the scene to update the tree stand-ins to now have rigidbodies
    8) Comment out line 464 in the Destructible.cs script in the OnCollisionEnter function: "if (!isActiveAndEnabled) return;". This will prevent collisions from being ignored on disabled Destructible scripts.

    Destructible Terrain Trees + Edy's Vehicle Physics (Video)



    Hope that helps! Let me know if you still have issues.
     
    Last edited: May 5, 2022
  9. tj_hooka

    tj_hooka

    Joined:
    Jul 4, 2019
    Posts:
    4
    Thanks very much for your help and glad to see you did videos for a handful of the Vehicles Physics packs cause I've been using a variety in different engines and seeing how you were troubleshooting was cool.



    Got lots more stuff to integrate/fix up but I'm glad it's going!
     
    zangad likes this.
  10. ParadoxSolutions

    ParadoxSolutions

    Joined:
    Jul 27, 2015
    Posts:
    325
    If there is anyone who doesn't want to pay the big bucks for RayFire but doesn't like Blender's cell fracture I found this free fracture tool for Unity on GitHub: https://github.com/U3DC/unity-libre-fracture

    Works pretty well.
     
    EpicMcDude and zangad like this.
  11. Nachoman

    Nachoman

    Joined:
    Oct 25, 2013
    Posts:
    2
    Hi, i bought this asset with humble bundle, but i can't find it in the packagemanager. All other assets are available. This is the only one that doesn't work. Any Idea?
     
  12. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @Nachoman,

    That's odd, no I'm not sure what could be going on, there. We haven't had any other reports of this issue so far, but thanks for bringing it to our attention.

    Unfortunately, we don't have any control over the keys, but I would imagine that you can let Humble or Unity know and they should be able to get you setup.

    Here is the customer support for Humble. Just explain that you are missing your key for DestroyIt and give them your Transaction ID: https://support.humblebundle.com/hc/en-us/requests/new

    And here is the customer support for Unity. You should be able to just copy/paste what you filled out on the Humble form, and let them know you're not seeing DestroyIt in your package manager.
    https://support.unity.com/hc/en-us/requests/new?ticket_form_id=65905

    I've also had good results just directly messaging companies on Twitter. Both Unity and Humble are very active, there.
     
    Last edited: Sep 23, 2022
  13. Dyntragos

    Dyntragos

    Joined:
    Jul 24, 2018
    Posts:
    29
    Hello, I've purchased The DestroyIt asset, and I'm tying to use it in conjunction with the PolygonDungeon asset pack, but I'm having trouble getting the progressive damage to display on the prefab objects in the pack. I added the details mask and the secondary masks as instructed, but no progressive damage will show. I simply press 0 four times to make the objects explode, but the progressive damage aspect is important the project I'm working on. It looks as thought the detail maps do not display anything when used with the mesh objects for the PolygonDungeon prefabs, because when I switch the mesh on the object to a standard cube, the damage displays correctly.

    If there is anything I can do to fix this, it would be much appreciated!
     
  14. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @Dyntragos,

    I have that pack, too, so I took a look at it and I see the same issue. Looking at the textures, I see the problem. The Synty models have UVs that point to a single pixel of color on the texture images. This allows Synty to produce an entire model pack with only 4 textures/materials. The downside is that there's very little texture data to work with. This means you can't use a detail map with these models, as far as I can tell.

    To clarify, the secondary detail map/mask *is* being used, you can see that the damage texture is being overlayed on top of the image correctly (the cracks in the bottom right of the material ball). But you don't see it on the barrel because the barrel's UVs only point to a couple of pixels on the texture.



    If I keep adjusting the offset/tiling of the damage texture, I can get it to where the cracks cover one or more of the pixels that the UV of the model points to, but that just makes a large portion of the barrel black - not really what we're looking for.

    So unfortunately, I don't see a way to use DestroyIt's progressive damage system with Synty models, or any low-poly models that only use a few pixels of texture data. There just isn't enough texture data on the model to display complex cracks or damage.

    The only ways I can think of to get this to work would be to re-UV the models you want to use with progressive damage, and make those models use a regular-sized texture and a different material. That's pretty complicated, though, and very labor intensive if you wanted to do a lot of assets that way. Plus, it kind of defeats the reason to use a low-poly pack like Synty's that has such a high degree of texture optimization. But re-UVing them would make the models have progressive damage with DestroyIt.

    The other way would be to use projectors to project damage textures onto the model. But that would probably be pretty bad, performance-wise. You would need to project the damage textures from multiple angles around the model, which means each of your models would need 6-8 projectors that would have dynamically-progressive images switched out at runtime. Not a simple task. But that would make it so you don't have to modify the models and still get the higher-resolution complex damage projected onto them.
     
    Dyntragos likes this.
  15. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hey @Dyntragos,

    I thought of another way you can get some progressive damage textures working with Synty models: adding a new UV map to the model and assigning the Secondary Map images to that. That way, you don't have to re-UV and re-texture every model, and the steps are pretty simple.

    Here's the results (the barrel is from Synty's Dungeon Pack):
    https://www.modelshark.com/content/images/DestroyIt-Synty-Barrel.gif

    Here's the steps to add the second UV map and setup the material in DestroyIt:
     
    shyamarama and Dyntragos like this.
  16. Joymagine

    Joymagine

    Joined:
    Nov 13, 2022
    Posts:
    3
    Terrain Trees with multiple Terrains in the Tree Manager?
    i could probably write it myself but throwing the question to you for a moment.
    Thanks.

    ...

    I got my car working with the Terrain Trees with your video :D

    now I got like 25 terrains in one scene ( car game need decently big level )

    I suppose the idea is to only have 1 active terrain, but that kinda doesnt work especially at an intersection.

    also Iam kinda newbie to terrains, but i thought having multiple 1km x 1km terrains was the way to go, especially I got tools that can handle editing on them well.
     
  17. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @Joymagine,

    Yes, as it's written, DestroyIt expects to handle only one active terrain in the scene. But you can change this if you know some coding, which it sounds like you do.

    What I would do is change the terrain public member variable on the TreeManager to an array, and either drag and drop my terrains into the array at design time, or programmatically load them into the array at runtime. Then, change the code in the OnEnable() method in TreeManager to loop through all the terrains in the terrain array and store all their terrain data in a dictionary, with the dictionary key being the index of the array, so you can keep track of which terrain each tree came from.

    Pretty much every method in TreeManager would need to be touched, to change from a single terrain to an array (or dictionary with the terrain index as key). But the logic shouldn't need to change - it's still just destroying and replacing terrain tree data at a specific coordinate on the terrain with the prototypes you've previously defined.

    One thing to note is that performance may be an issue if you're trying to manage thousands of destructible terrain trees across 25 terrains in a single scene. It probably comes down to how many total trees you have, how complex your colliders for them are, and how many trees the player can see/destroy at once.
     
    Joymagine likes this.
  18. dfernand

    dfernand

    Joined:
    Jun 21, 2014
    Posts:
    9
    Will DestroyIt used with a URP Pipeline Unity project work on a gaming console target platform e.g. PS4, PS5, XBox One etc. ? I'm asking because Rayfire which is another 3D destructive package will NOT work for videogame consoles.
     
  19. zangad

    zangad

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

    DestroyIt does work with the URP pipeline, but we haven’t tested it with a console target platform, so I can’t say for sure whether it would work with that or not.
     
    dfernand likes this.
  20. bbaugh007

    bbaugh007

    Joined:
    Jul 23, 2018
    Posts:
    39
    Hello, is there a tutorial for working with support points to make more realistic holes in walls when a cannonball goes through? I'm unsure of how support points work and how to prevent new destructible objects from exploding entirely when receiving damage.
     
  21. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @bbaugh007,

    The support points are really designed to just add a little clinging debris to objects that are supported by other, larger structures - like a window in a building - the system is there to let some of the pieces continue clinging to the frame for a more realistic effect. I wouldn't try to use support points to make realistic cannonball holes through doors.

    For that, you would first need to break your object up a lot, into really small pieces. Probably 100-200 or more debris pieces for a single wall. Performance will become an issue quickly if you create an entire building made of walls with this many debris pieces, but it can be done.

    I'm not sure I understand what you mean by objects exploding entirely when they receive damage - that sounds like you are using a particle effect and maybe the cannonball is doing too much damage and you have Can Be Obliterated checked on your Destructible object. If that is checked, then when it receives 3x the amount of damage it has, then it just explodes into the particle effect. You can turn this off by un-checking Can Be Obliterated. Also, if you are only using a fallback particle effect (no destroyed prefab), you will get that same effect because there is nothing else for the object to destroy into.
     
    bbaugh007 likes this.
  22. bbaugh007

    bbaugh007

    Joined:
    Jul 23, 2018
    Posts:
    39
    The goal is to have an imported house object's walls behave like the walls of the example tower object in the attached images.
     

    Attached Files:

    Last edited: Dec 1, 2022
  23. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Oh ok, so you just need to know how to use the cling points to get the same effect as the tower in the demo scene?

    We don't have a video tutorial of that process specifically, but if you look in the DestroyIt User Guide on page 14 it illustrates how to position the Cling Points.

    From the user guide:

    "You add the Cling Point script to colliders on your destroyed prefab. When debris is spawned, the DestroyIt system looks for cling points and raycasts against adjacent colliders. If the raycast hits something, it rolls a percent chance based on Chance to Cling that you specify. If it passes that check, it strips the rigidbodies off the debris piece and parents it under the object it clings to. This provides better performance and a rock-solid joint over hinge joints.

    To the right is an illustration showing how cling points appear in the inspector. This is the destroyed prefab for the glass pane. On the edges, you can see the “pin” gizmos that indicate the direction the raycasts will be fired from the debris piece to check for adjacent colliders to cling to."


    So you just need to place the Cling Points so the pin gizmos point to the object you want the debris piece to cling to. I hope that helps. Please let me know if you have any specific issues getting it to work.
     
    bbaugh007 likes this.
  24. bbaugh007

    bbaugh007

    Joined:
    Jul 23, 2018
    Posts:
    39
    Thank you!
     
  25. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Hi Zangad,

    I've updated Destroyit and re-imported it to my project but I don't have the new stuff from 1.15, and the changelog textfile still says 1.14.
    upload_2023-1-1_20-6-4.png
    There is no "Limit Damaged" tick visible in the component.
    On the package manager window there's still only the v1.14 changelog textfile, and you can see I have imported the current version of 1.15.
    upload_2023-1-1_20-8-57.png
     
  26. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @EpicMcDude,

    Sorry you're having issues getting the latest version. Sometimes, the Unity package manager seems to want to hang onto the cached version of an asset. I've had this issue a couple of times with other developers' assets, and we've seen it a few times with our other asset (ProTips).

    The problem seems to be with the Package Manager (more info here). But there's a workaround:

    Go to your %AppData% folder where your Unity asset cache is, and delete the ModelShark Studio folder (C:\Users\[YOURNAME]\AppData\Roaming\Unity\Asset Store-5.x\ModelShark Studio). That will remove all of the cached versions of DestroyIt you may have downloaded. Then, restart the Unity editor (refreshing wasn't enough for me) and open the Package Manager again, and you should be able to download and import the new version.

    If that doesn't work for you, or if you're using a much older version of Unity and trying to install the newest version of DestroyIt, please send us an email at modelsharkstudio@gmail.com and we'll send you a unitypackage containing the latest version, which you can just import directly.
     
    EpicMcDude likes this.
  27. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Oh wow, so this has been happening for more than 2 years now... I'm on 2020.3.26, I noticed on your changelogs the updated versions have compatibility for 2020.3.4 and 2020.3.32, maybe the Unity Editor version I'm using refuses to download the newest build because of this? Not sure, but I'll have to send you an email as deleting the folder and restarting Unity did not work for me.

    Thank you for the help as always
     
  28. BrandenU

    BrandenU

    Joined:
    Aug 18, 2015
    Posts:
    2
    Hi, I just started using this asset and I'm enjoying it so far, but I'd like to use it with Playmaker since I'm not so good at scripting. Unfortunately, every time I install the Playmaker integration package under the extras folder I get errors that prevent me from playing the game.
    For example:
    Assets\DestroyIt\Extras (safe to delete)\PlayMaker\Actions\RepairDestructibleObject.cs(29,75): error CS1061: 'Destructible' does not contain a definition for 'totalHitPoints' and no accessible extension method 'totalHitPoints' accepting a first argument of type 'Destructible' could be found (are you missing a using directive or an assembly reference?)

    There are 3 other error messages that are the same but "Destructible does not contain a definition for 'currentHitPoints'" and the same two errors but for DestroyDestructibleObject.cs.

    Has anybody else encountered this issue?
     
  29. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @BrandenU,

    Sorry you ran into that issue. It happened because I changed a couple of variable names in the main DestroyIt package, but forgot to update the PlayMaker integration package. I've already corrected this on my development copy of DestroyIt, but haven't submitted the change to the Asset Store yet, since it was so small.

    Please try importing this unity asset package, which will replace your PlayMaker integration files and fix the variable naming issue:

    https://app.box.com/s/fhk2h405mlem8pj3v32ovnjcu53pvrsh

    Please let me know if that doesn't fix it for you.
     
    Last edited: May 19, 2023
  30. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    Hello,

    Have you tried DestoryIt with the V3 versions of the Opsive Character controllers?

    I just saw the Edy's and Destory It video above, so good
     
  31. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    I haven't tried V3 of the Opsive Character controllers yet. It looks like they just came out (Mar 16, 2023)? I checked and I only have the V2 version right now.

    It looks like a major release, though. Lots of changes/enhancements:
    https://opsive.com/news/character-controller-version-3-features/
     
  32. nathanjams

    nathanjams

    Joined:
    Jul 27, 2016
    Posts:
    304
    It was released late last year but is finally becoming stable, all the integrations are done and all but one of the addons are done. It was a rewrite of the asset. You should message the dev and see if you have get a copy of v3 to update your integration, if you have the time of course.
     
    zangad likes this.
  33. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Hey Zangad!

    I'm having an issue with re-parenting a child of the destroyed prefab so that I can get the same results as in the demo scene of the sword handle being seamlessly re-parented to a hand.

    upload_2023-4-10_22-29-47.png

    I have my destroyed prefab as the Destroyed Chair, which holds all these children.
    upload_2023-4-10_22-30-44.png
    I only want to re-parent the Chair Leg to the player's hand but the Destroyed Chair parent from the prefab also gets parented to the player's hand. Is there any way to avoid this and also retrieve child game object from the instanced prefab (as soon as it spawns without getting the child from the Melee Holder) so that I can control what to do with it?
    upload_2023-4-10_22-42-13.png

    Thank you!
     
    Last edited: Apr 11, 2023
  34. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hey @EpicMcDude,

    That's really strange, I'm not sure off the top of my head why that would be happening. I'd like to take a look at it and see if I can reproduce the issue on my end.

    Is there a way you could send me a unitypackage of your pristine and destroyed chair? You can select both prefabs in your project and then right-click one of them and choose Export Package.

    upload_2023-4-10_20-52-23.png

    On the next dialog, make sure to check Include Dependencies.

    upload_2023-4-10_21-0-50.png

    Then just send me the resulting unitypackage. That should give me something I can import into my project to see if I can reproduce the issue. You're also welcome to just send me your whole project if it's not too big (zip it up at the root folder level, and you can delete the /bin, /Library, and /Logs folder to save space, then upload to a cloud hosting service and send the link to modelsharkstudio@gmail.com).
     
  35. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    117
    Thanks for the quick reply! I was testing stuff and I'm sure I misunderstood its purpose as It's doing what it's suppose to do.
    I was trying to make the Chair Leg a child of the Assigned Parent object, but that option is for re-parenting the whole destroyed prefab object, not what I wanted.
    I was thinking the "Debris to re-parent" would be what child object, out of the destroyed prefab, would be made a child of the Assigned Parent, so that's my bad.

    Would you know how I could get a reference to a child object of the instantiated destroyed prefab as soon as it spawns so that I can re-parent that instead of the whole destroyed prefab?

    EDIT: I figured it out, I'm doing some stuff I wanted to avoid but it works.
     
    Last edited: Apr 11, 2023
    zangad likes this.
  36. dulinieck

    dulinieck

    Joined:
    May 27, 2021
    Posts:
    24
    I have strange issue - I cannot select the level of visual damage when I use my own materials with name/suffix "-ProgDamage". Is it because my material is not in DestroyIt folder?
    upload_2023-4-25_21-48-24.png
    in my material I only added detail mask and secondary normal map - and visual damage works but I cannot edit showed above greyed column

    ok - I missed filling secondary map - detail albedo - I missed it because efect was still visible - just in script only the whole column was not editable
     
    Last edited: Apr 25, 2023
    zangad likes this.
  37. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @dulinieck,

    Thank you for letting me know you got it figured out. Yes, if you're missing the Secondary Detail map, it won't let you edit those values. I'll look to see if there's a tooltip or something I can add to the inspector script to make it more clear that a Secondary Detail map is required for editing.
     
  38. dulinieck

    dulinieck

    Joined:
    May 27, 2021
    Posts:
    24
    do you plan to add any i.e. simplified version of "pre-fracture generation" ?
    I assume that for now I need to use external tool i.e. Open Fracture (or blender but it is outside unity) to create "fractured version" of my destructible objects.
     
    Last edited: Apr 27, 2023
  39. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @dulinieck,

    No, not at this time. While I would like to add a pre-fracturing feature to DestroyIt, I haven't found a way to add something I think customers would find acceptable in quality. I tried to add this feature in the past, using an open-source 3D Voronoi fracturing C# library. However, I quickly ran into issues with even mildly complex geometry. Here's the post where I go into more detail if you're interested in what I've tried and what I discovered.

    The problem is, it would require a lot of effort to recreate this feature, which already exists for free with Blender. Not only that, but Blender (and other fracturing assets) already solved most of the challenges with fracturing meshes. So there are years of refinement with Blender's fracturing feature, making it a better tool than I would be able to create on my own. For example, Blender has a grease pencil that lets you draw custom patterns and fracture the mesh based on the pattern. So you could draw concentric circles with the grease pencil and get a very realistic broken glass effect with a spiderweb fracture emanating from the center in rings.

    The only benefit I can see of adding this feature to DestroyIt is the convenience of not needing to use an external tool. I admit this is a big benefit, and I would like to add it someday, but so far I haven't seen a way to make it feasible from a development standpoint. If you know of a script/library/API that works (it needs to be open-source, or available to use for commercial purposes), I would definitely be willing to take a look at it. I get a lot of requests for this feature, so I'm always on the lookout for a way to make it happen. :)
     
    dulinieck likes this.
  40. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    406
    Unity version 2021.3.24f1
    Playmaker ver 1.9.6
    DestroyIt ver 1.15

    Get this error and oters after adding the destroyit playmaker package.
    Playmaker is installed

    Assets\DestroyIt\Extras (safe to delete)\PlayMaker\Actions\RepairDestructibleObject.cs(29,48): error CS1061: 'Destructible' does not contain a definition for 'currentHitPoints' and no accessible extension method 'currentHitPoints' accepting a first argument of type 'Destructible' could be found (are you missing a using directive or an assembly reference?)
     
  41. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @eagleeyez

    My apologies for this error, I'm currently working on a DestroyIt update that will be submitted to the Asset Store soon which fixes it.

    In the meantime, please try importing this unity asset package, which will replace your PlayMaker integration files and fix the variable naming issue:

    https://app.box.com/s/fhk2h405mlem8pj3v32ovnjcu53pvrsh

    Please let me know if that doesn't fix it for you.
     
  42. greatUnityGamer

    greatUnityGamer

    Joined:
    Aug 11, 2013
    Posts:
    182
    Hello , i got destory it on Unity 2021.3.18f. I just want objects to get destroyed either immediately when i throw objects at them( balls, rocks etc) or after a few hits. I using URP and i intend for Quest 2 VR. I'm not even sure if your product works in VR . does it? But also i'm not sure how to set up the Destory it on the objects to be destroyed. The PDF says to put the destructible script and that's what i do but nothing happens when i throw a ball/rock etc at the object. None of the sounds that i have in the Damaged Sound play. I am believing Damaged Sound means the sound when collision happens. is that right? Then nothing is playing.
    Also, how do i make it some items to be destroyed with one collision. And some items to require several hits before destoryed?

    Do i have to put the Detructible script at same object where the Mesh Renderer is or can it be anywhere. Some Prefabs from bought products can have nothing in the parent of the prefab then have the mesh render in the children and sometimes they do't contain box collider or rigidbodies. Should the items that i put destructible script, all need colliders and Rigidbodies too and should all those comonents be in the same object?
    I have the latest DestroyIt version 1.15

    thanks
     
  43. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @greatUnityGamer,

    Thanks for reaching out with your questions. I'll try to answer each one here.

    1) Does DestroyIt work in VR?
    I haven't personally tried DestroyIt with VR, but one of our customers released a VR game on Steam that uses DestroyIt and they mentioned that it worked great.
    http://store.steampowered.com/app/468740

    2) How do I setup Destructible objects?
    Put the Destructible script on your game object at the same level (or higher) than your object's colliders. You can refer to the Main Scenarios Scene, which is the main demo scene for DestroyIt, to see how the Destructible script is placed on the objects in the scene. There are a lot of examples in that scene that cover many different situations: no colliders, simple colliders, complex colliders, nested game objects, etc. It's worth checking out if you haven't already, just to get some ideas of how to use it.

    3) Nothing happens when I throw a ball/rock at the Destructible object?
    Does your destructible object have colliders on it? If you want it to react to collisions, it's going to need some type of collider on it. Are your colliders trigger colliders? DestroyIt ignores trigger colliders, since those types of colliders are not for physics collisions. If your object has mesh colliders on it, are they marked as Convex? If not, that could be the culprit. You might also check to make sure your colliders are not assigned to a Layer that ignores physics. Also, check the collider on your projectile to make sure there is one, and that it also is convex (if it's a mesh collider).

    4) Does not play the Damaged Sound when assigned?
    I'm not sure why this is happening, unless your object isn't being damaged by each hit. You can check this by throwing a rock at the object and then switching to the Scene view while the game is running and select the destructible object and look at its Hit Points on the Destructible component. If the hit points are not going down, then it's not actually taking damage. In that case, I would take a closer look at your colliders/layers (see #3 above).
    Also, do you get the same results when you test in the Main Scenarios Scene? I just tried it out myself by selecting the #3 Progressive Damage object in the demo scene and assigning the Damaged Sound and it worked fine. If it works in the DestroyIt demo scene but doesn't work in your custom scene, then maybe your scene doesn't have an Audio Source? Check your console log to see if it is warning you about not having an audio listener.

    5) How do I make a destructible object destroy with only one collision?
    There are a couple of ways to do this. The easiest is to just set the Total Hitpoints on the Destructible component to 1 hit point. Practically anything that hits it with any significant force will destroy it immediately. The other way to do it, which will guarantee destruction every time no matter the collision force, is to set the damage limits on the Destructible script to a range that is 1 higher than your object's hit points:

    upload_2023-6-12_13-38-46.png

    The object in this case has 60 hit points, but I have limited the damage to always be 61 hit points with any hit, which will cause the object to be destroyed every time, no matter what collided with it.

    6) Do I have to put the Destructible script at same object where the Mesh Renderer is?
    No, if you look at Scenario #10 (sword in the stone) in the Main Scenarios Scene, you'll see that it has the Destructible script at the top level and the mesh renderer for the rock is two children under it. I don't think it would work if you want to put the Destructible script on an object that is a child of the mesh renderer parent, and you want that mesh renderer parent to be affected by the Destructible script. But as long as the mesh renderer is a child somewhere under the Destructible script component, it should be fine.

    7) Do my objects that have the Destructible script need colliders and rigidbodies?
    If you want them to react to physics such as collisions (which it sounds like you do), then yes, you need colliders and rigidbodies on your objects. Rigidbodies are not entirely necessary, but colliders are. No colliders means the object will not register collisions, and therefore won't do anything when an object passes through it. This isn't anything to do with DestroyIt, it's just how Unity works. The Main Scenarios Scene in the DestroyIt package has a lot of examples of using rigidbodies, colliders, static colliders, no rigidbodies, etc. There's even one Scenario #29 No Rigidbody or Collider, which demonstrates how to destroy an object without either rigidbodies or colliders. That's probably not the effect you want, but it does show that technically, you do not need either of those components to damage or destroy a destructible object. However, if you want to throw a rock at it and have it take damage from the collision with the rock (instead of the rock just passing through it), then you will need a collider on your object at the same level or lower (a child) of the object the Destructible script is on.

    Hope that helps! If you're still having trouble, you can always upload your project to a cloud hosting site and send me the link (modelsharkstudio@gmail.com) and I'll take a look at it.
     
  44. MaxKMadiath

    MaxKMadiath

    Joined:
    Dec 10, 2016
    Posts:
    69
    @zangad Hi which script i need to use for the latest invector shooter template 2.6.3
     
  45. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @MaxKMadiath,

    I just tested this with version 2.6.3 and it still works fine for me. Let me know if you have any issues.

    Instructions for using DestroyIt with Invector TPC Shooter Template v2.6.3

    Steps:
    1. Import DestroyIt into your Invector Third Person Controller Shooter Template project.
    2. Import the DestroyIt Scripts for Invector TPC Shooter 1v5.unitypackage.
    3. From the top menu in Unity, choose Window => DestroyIt => Setup Minimal.
    4. Add the Destructible script to an object you want to make destructible.
    5. Add the vDestructible script to the same object, and at the same level.
    6. Run the scene. You should be able to shoot the destructible object and damage and destroy it.
     
  46. templetime45

    templetime45

    Joined:
    Jul 26, 2023
    Posts:
    17
    @DeadlyAccurate @zangad Assets\DestroyIt\Scripts\Managers\TreeManager.cs(65,33): warning CS0618: 'Object.FindObjectOfType<T>()' is obsolete: 'Object.FindObjectOfType has been deprecated. Use Object.FindFirstObjectByType instead or if finding any instance is acceptable the faster Object.FindAnyObjectByType'
    Assets\DestroyIt\Demos (safe to delete)\Scripts\Gizmos\EditorGizmos.cs(22,34): warning CS0618: 'Object.FindObjectsOfType<T>()' is obsolete: 'Object.FindObjectsOfType has been deprecated. Use Object.FindObjectsByType instead which lets you decide whether you need the results sorted or not. FindObjectsOfType sorts the results by InstanceID but if you do not need this using FindObjectSortMode.None is considerably faster.'
    Assets\DestroyIt\Scripts\Behaviors\DestructionTest.cs(23,47): warning CS0618: 'Object.FindObjectsOfType<T>()' is obsolete: 'Object.FindObjectsOfType has been deprecated. Use Object.FindObjectsByType instead which lets you decide whether you need the results sorted or not. FindObjectsOfType sorts the results by InstanceID but if you do not need this using FindObjectSortMode.None is considerably faster.'
    Assets\DestroyIt\Scripts\Managers\ObjectPool.cs(47,40): warning CS0618: 'Object.FindObjectsOfType<T>()' is obsolete: 'Object.FindObjectsOfType has been deprecated. Use Object.FindObjectsByType instead which lets you decide whether you need the results sorted or not. FindObjectsOfType sorts the results by InstanceID but if you do not need this using FindObjectSortMode.None is considerably faster.'
    Assets\DestroyIt\Scripts\Managers\DestructionManager.cs(92,33): warning CS0618: 'Object.FindObjectOfType<T>()' is obsolete: 'Object.FindObjectOfType has been deprecated. Use Object.FindFirstObjectByType instead or if finding any instance is acceptable the faster Object.FindAnyObjectByType'
    Assets\DestroyIt\Demos (safe to delete)\Scripts\Managers\InputManager.cs(289,43): warning CS0618: 'Object.FindObjectsOfType(Type)' is obsolete: 'Object.FindObjectsOfType has been deprecated. Use Object.FindObjectsByType instead which lets you decide whether you need the results sorted or not. FindObjectsOfType sorts the results by InstanceID, but if you do not need this using FindObjectSortMode.None is considerably faster.'
    Assets\DestroyIt\Demos (safe to delete)\Scripts\Managers\InputManager.cs(466,43): warning CS0618: 'Object.FindObjectsOfType(Type)' is obsolete: 'Object.FindObjectsOfType has been deprecated. Use Object.FindObjectsByType instead which lets you decide whether you need the results sorted or not. FindObjectsOfType sorts the results by InstanceID, but if you do not need this using FindObjectSortMode.None is considerably faster.'
    Assets\DestroyIt\Demos (safe to delete)\Scripts\Managers\InputManager.cs(478,43): warning CS0618: 'Object.FindObjectsOfType(Type)' is obsolete: 'Object.FindObjectsOfType has been deprecated. Use Object.FindObjectsByType instead which lets you decide whether you need the results sorted or not. FindObjectsOfType sorts the results by InstanceID, but if you do not need this using FindObjectSortMode.None is considerably faster.'
     
  47. templetime45

    templetime45

    Joined:
    Jul 26, 2023
    Posts:
    17
  48. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @templetime45,

    These are warnings about deprecated method calls, not errors. I just created a new Unity 2023 project and tested DestroyIt with it and it worked fine. I'm here to help if you have any issues, just let me know. :)
     
  49. MaxKMadiath

    MaxKMadiath

    Joined:
    Dec 10, 2016
    Posts:
    69
    I am getting errors at the time of builds. Unity 2022.3.5f1. Thanks
     

    Attached Files:

  50. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @MaxKMadiath

    I just imported DestroyIt into a new Unity 2022.3.5f1 project, and I don't get any errors. It works fine for me.

    I looked at the error you posted a screenshot of a little closer. The "MenuItem" that it is complaining about is an Attribute. I'm wondering if maybe the code got changed, like a bracket removed or something accidental. You might try re-importing DestroyIt and overwrite that file if it has changed. Otherwise, I'm not seeing anything that would fail with that file.

    Please let me know what you find out, especially if re-importing the file didn't fix it. If there's an error I'm not able to see for some reason, I'd like to be able to fix it. Could you send me your copy of the HideFlagsUtility.cs file to modelsharkstudio@gmail.com?