Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

[Released] DestroyIt - Cinematic Destruction System

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

  1. Bitcore

    Bitcore

    Joined:
    Apr 14, 2018
    Posts:
    4

    1) NWH Vehicle Physics 2
    2) Realistic style, something similar to SPINTIRES .
    3) Yes, that's correct. Vehicle controller script seems to be overwriting some of the rigidbody's variables, as it's simulating other physical properties of the car, like center of mass and inertia tensor. Annotation 2020-10-22 174901.png
    So far I'm using the four given vehicle prefabs: Niva, MosterTruck, SportsCar, RocketRarrier.

    Thank you for looking in to it!
     
  2. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hey @Bitcore,

    Thanks for the info and screenshots. Unfortunately, the developer of NWH Vehicle Physics 2 is unable to provide us with a voucher so we can setup an integration test, so we'll need you to send us your project so we can take a look at it and troubleshoot the issue.

    If possible, please email us a link to your zipped-up project (and provide the Unity version you're using) to modelsharkstudio@gmail.com. Dropbox, OneDrive, or GoogleDrive all work well for hosting. You can also export your project as a *.unityproject file and we'll import it into a new project on our end.
     
  3. OmnifariousStudios

    OmnifariousStudios

    Joined:
    Mar 12, 2018
    Posts:
    20
    Hi again!

    Working on a multiplayer VR game, and wondering if you guys had any advice for using Normcore with your system?

    Thanks, and great asset as always.
     
  4. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hi @CoryRobertson,

    We haven't used Normcore with DestroyIt. It looks pretty neat, though, especially the physics synchronization. As far as potential issues with DestroyIt, I would pay close attention to how it handles/syncs objects and particle effects that are spawned in. For instance, in Photon, when an object is created, you need to attach a PhotonView component to it so the system knows to sync changes to the object (position, rotation, material changes, etc) across the network. As long as Normcore has some way to "tag" objects as network observable, that should work fine.

    Also, I'd probably go light on persistent debris until I knew how much the network could handle reliably. Many pieces of persistent debris being synced across the network could make it very chatty and bog the game down. So I'd use less-expensive particle effects for all non-essential destruction in a multiplayer network game.
     
  5. OmnifariousStudios

    OmnifariousStudios

    Joined:
    Mar 12, 2018
    Posts:
    20
    Thanks for the info! Normcore is actually great about that. You can just add View and Transform components to a prefab and then call their version of Instantiate and you're done.

    I'll keep an eye on how many debris objects I'm allowing too, that's a good point.

    If you ever get the time, you should dive into the normcore docs, I think it would work great with your asset.

    Cheers
     
  6. lanrosta

    lanrosta

    Joined:
    Oct 11, 2014
    Posts:
    26
    Does the destructible terrain trees work on Unity 2019 or Unity 2020? I am not having any success getting the Terrain Trees to be destroyed in these versions. I have not tested Unity 2018 yet as I do not use that version.. I have followed the Terrain Trees tutorial PDF to a T, but am not having any luck with them falling over when hit. When I drag the _PRIST prefab to the scene hierarchy, the tree is destructible, but the Terrain painted trees using the same prefab are not, I have run the 'Update Trees', but still no luck. Can you please help identify why I may be having this issue?
     
  7. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hi @lanrosta,

    The destructible terrain trees should work fine with Unity 2019 and 2020. Are you using trees that you made with the Unity tree creator, or SpeedTree trees, or from the asset store? If they are not falling over, my first thought is to check if the destroyed versions have rigidbodies on them, and if so make sure isKinematic is unchecked on the rigidbody. Then, put your destroyed tree in the scene by itself, run the scene, and see if it falls over. If it does, then you know it's not a problem with the destroyed tree.

    The other reason I can think off off-hand is that maybe the trees aren't actually switching over to the destroyed version for some reason. When you destroy a tree while the scene is running, switch over to the scene tab and find the tree and see if it switched over to destroyed prefab correctly. If you don't see the destroyed version of your tree in the scene, then it might not be doing the switch properly. In that case, I would check the terrain trees in the scene while the game is running to make sure they have the Destructible script on them and have colliders.

    Hope that helps! And if you're still stuck after trying these troubleshooting steps, you can always zip up and send us your project (as a link uploaded to DropBox/OneDrive/GoogleDrive) and we'll download it and take a look!
     
  8. lanrosta

    lanrosta

    Joined:
    Oct 11, 2014
    Posts:
    26
    Ok, I looked in your demo and saw the Terrain Tree 'Palm tree' example in there working in 2019 and 2020. It appears my issue was that I am using GPU Instancer for Terrain Details and Terrain Trees, and this seems to make the DestroyIt Terrain Tree stuff not work. However, I was able to use GPU Instancer's Prefab Manager (along with a Prefab Painting tool) to get excellent results with thousands of destroyable trees and still above 125fps. Would be great if you could work with the GPU Instancer devs to get integration there with Terrain Trees, but I still get good results with non-terrain GPU instanced prefab trees. I'll ask them about it as well. With faster video cards becoming more common in desktops, I think the GPU is a better place to handle the load for lots of terrain details and trees.
     
  9. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hi @lanrosta,

    I'm glad you found a workaround for the destructible terrain trees. I haven't looked at the GPU Instancer yet, but I did put it on our DestroyIt roadmap for research. The framerates you're getting with GPU Instancer definitely sounds promising! And I agree, the more we can offload to the GPU, the better in terms of performance. I think it would make a nice option for desktop/PC developers.

    Thank you for suggesting the feature! :)
     
    julianr likes this.
  10. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    27
    Hey @zangad

    Love the asset!
    Hoping you could help me with a pet peeve, I'm not sure if this is an issue with the asset or not.
    I have a simple mechanic of grabbing and throwing objects, when I throw them at Destructible objects, the thrown object loses all of its momentum and velocity when it collides with the Destructible object. The thrown force is 20.

    I realize you have an option in the script called "Velocity reduction" to counter this effect but it doesn't do anything for me, either at 0 or 1 it stops the thrown object dead in its tracks at the same speed.
    I tried throwing objects with different mass and they all behave the same way once they collide onto a Destructible object.

    Is there any to stop this from happening?
     
  11. zangad

    zangad

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

    Thanks for reaching out to us with your question. I have an idea as to why this might be happening: Does your destructible object have a rigidbody attached to it?

    If not, you will need to add the RigidbodyProjectile.cs script to your thrown object so it will register collisions, and tell the Destructible object to apply the right amount of damage and reset the velocity of the rigidbody object after the collision. You can find the RigidbodyProjectile.cs script in \Assets\DestroyIt\Demos (safe to delete)\Scripts\Weapons.

    If this doesn't fix it, or if your destructible object already had a rigidbody on it, please let me know and I can do some more troubleshooting. There are a lot of variables to consider, so if possible, I'd like to take a look at your project. You can upload your project to a cloud host (Dropbox, OneDrive, Google Drive, etc) and send me a link at modelsharkstudio@gmail.com.

    Hope that helps!
     
    EpicMcDude likes this.
  12. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    27
    Thank you for the quick response!

    Important notice: I'm using Playmaker for logice, I understand C# but can't write it yet.

    Yeah, I'm testing the asset with the stuff you created, in this case one of the columns and they have a rigidbody component in them.

    I attached that script to my thrown object but it's still the same. The problem is that the momentum and velocity of the thrown object does not transfer to the destroyed prefab that is assigned to the Destructible object.

    I uploaded a video to demonstrate this:



    In the video, I put the Column Destructible object with 1000 HP and it reacted properly like a Rigidbody would when getting something heavy thrown at it, but the other columns with 50 HP make the thrown object stop.

    I guess the issue is more of having an object hit velocity transfer over to the destroyed prefab.

    If this is something that can't be easily fixed or you would still like me to send the project over your way let me know!

    Thanks again.
     
  13. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    @EpicMcDude,

    Thanks for the video, that helps me visualize the issue.

    I'm wondering if maybe the mass is set too high on the destroyed prefab's debris pieces, at least in relation to the mass of the thrown ball. Can you check the mass of the debris pieces and make sure they are appropriate?

    A few questions:

    What is the mass of the thrown ball?
    What is the mass of the pristine (un-destroyed) column?
    What is the mass of the debris pieces on the destroyed column?

    If the debris pieces have a low mass in relation to the thrown ball, then yes, I would think the ball should scatter them like bowling pins. But if high mass of the debris pieces is not the issue, the next thing I would look at is the physics material on the collider. I noticed in your video that the wooden ball has a Wood physics material. I'd inspect the Friction properties of that material to make sure it's not losing too much of its velocity with collisions.

    If those ideas don't help fix the issue, then yes, I'd like to take a look at your project and see how the thrown ball differs from the cannonball in our demo scene. Thanks!
     
  14. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    27
    The debris do act accordingly, since I'm just using the prefabs from the Demo scene the mass is the what they were set to.
    So mass of the thrown ball is 30, mass of the pristine column is 6 and of the destroyed debris is 1.

    I checked the friction on my thrown object material and set it all to 0, but had the same results unfortunately.

    This also happens to a cube I fractured in Blender and imported into Unity, it seems none of the objects with the Destructible script get affected by the physics of a thrown object.

    But I'll send you over the project link via email in a bit!
     
  15. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    27
    Hi again @zangad

    I wanted to post this here just in case anyone has the same question, I searched the thread but couldn't find anything about this (apologies if this was asked before).

    I'm trying to make realistic holes in the walls on the point of impact - in other words have the destructible prefab spawn in on the point of impact, or have only this set of debris affected, instead of having the whole wall crumbling down, from, for example, a bullet.

    I've been thinking of some ways to do this, but I'm not sure if they would work.

    I've been playing around with cling points on the debris, but they don't really achieve what I'm after since the debris cling to a collider and stay there regardless of the damage applied to them, they only fall off if the collider they are attached to gets damaged or disappears if I understand correctly (?).

    The other way is probably the way you made the tower in the "Main Scenarios" scene, and attach the debris through cling points to a bunch of poles with hinge joints (or support points?) and build a house this way?

    I've also tried making 12 1x1 (meters) cube (each cube a Destructible) to make a 3x4 wall, this might work if I tile the wall with cubes defined as side, bottom, top and center? And attach cling points correctly to each debris?

    It would be great to have your input on this! Thanks!
     
  16. AlanGreyjoy

    AlanGreyjoy

    Joined:
    Jul 25, 2014
    Posts:
    192
    Any progress with URP?
     
  17. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hi @AlanGreyjoy,

    Actually, yes, we are in the final testing of our next DestroyIt release, which will include a custom Shader Graph shader for URP. (Note that DestroyIt already works with URP with the exception of progressive damage textures. This shader just gives you that feature for URP, too).

    If you already own DestroyIt and just need the URP custom shaders, here is what we will be including in the next release. Just import this into your project and change your URP/Lit materials to use one of these ShaderGraph shaders (one is for solid and the other is for transparent objects).

    DestroyIt URP Shader Graph Shaders:
    http://www.modelshark.com/content/misc/DestroyIt-URP-Progressive-Damage-Shaders.unitypackage

    And here's the page in our updated user guide (to be released soon) that explains how to use the custom Shader Graph shader to get progressive damage for URP.

    Progressive Damage for URP:
    http://www.modelshark.com/content/misc/DestroyIt-User-Guide-URP.pdf

    Hope that helps! If you get a chance to try it out, please let us know if you have any issues with it. All of this will be included in the next DestroyIt package, which we will be submitting to the Asset Store very soon.
     
    Last edited: Apr 7, 2021
    julianr likes this.
  18. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    183
    Submitted v1.13 to the Asset Store.

    v1.13 Changelog (Apr 2021)

    • Updated to Unity 2020.3.2f1 (LTS)
    • Two new URP Shader Graph shaders were added to support the Universal Render Pipeline with progressive damage textures.
    • Destructible terrain trees now support parent LOD Group components, so they are able to randomly rotate when painted on terrain.
    • ChipAwayDebris was modified so it now removes any non-kinematic rigidbodies it finds on the destroyed prefab before spawning in.
    • New Feature: Structure-Supported Debris (Scenario #30). Allows you to quickly add structural support joints to fractured debris so it stays together.
    • Added the text "REPAIR" to the wrench HUD UI so it's more obvious that it's a repair tool, not a weapon.
    • Destructible terrain trees are now hidden when destroyed and remain part of the terrain data, removing the need for resetting tree instances and terrain height.
     
    julianr likes this.
  19. StevoFx

    StevoFx

    Joined:
    Apr 1, 2020
    Posts:
    8
    Hi, how can I get the default fallback particles working with objects that use a shared material with many colours on it? My objects are low poly and for optimisation they all use a colour pallete as a material, and are then are UV mapped to the correct colour. However when destroyed, the particles that are created are a rainbow of random colours from this material rather than the same colour the object is using. Is there any way around this? I have had to create custom particles for each colour so far but was hoping there was a quicker way. Thanks.
     
    zangad likes this.
  20. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hi @StevoFx,

    Have you already tried setting the Material Override for your fallback particle?

    Material Override for Fallback Particle:


    This lets you create a new material for each destructible object's particle effect, but still re-use the same particle effect. And you could specify just a single color in the Material Override material's albedo.

    If you're already aware of that feature and don't want to create multiple materials for your game, we could take look at adding something like a Color Override for the Fallback Particle. That would allow you to choose a color to override for the particle effect for each destructible object. The code would swap out the color on the material's Albedo with the color in Color Override. This would save materials (for performance) but probably wouldn't save you much time, since creating a material with a single color and using that as the Material Override (above) is probably about as time consuming as specifying a single color on each Color Override.
     
  21. StevoFx

    StevoFx

    Joined:
    Apr 1, 2020
    Posts:
    8
    Thanks for the quick response! I did know about that option but must have forgot at some point as I have been creating variations of the particles with different colours.

    However there is also a reason I started doing this, which is due to the fact that lots of my game objects are small props (it's a VR game where every item is destructible, hence why I have been trying to optimise materials at least!). The small particles are still a bit too big so I created my own tiny particle system and have been using that, at which point if you drag in your own particle system it removes the option to override the material. If you are open to suggestions, then a size override would be an amazing option so you could select any of the default particle systems and even add your own sizes or shapes (for example defaulting to the wood splinter particles). I also have a few mesh's from asset packs that for some reason default to the large particle system even if they are small so it would fix that too. No pressure of course as this asset is already very useful!
     
  22. EpicMcDude

    EpicMcDude

    Joined:
    Apr 15, 2013
    Posts:
    27
    Sweet, cool update! Can't wait to play around with the new feature.
    Thank you for the URP extras as well!
     
    zangad likes this.
  23. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    183
    Small 1.14 update submitted to the asset store today.
    • Updated to Unity 2020.3.4f1 (LTS)
    • New Feature: You can now override the fallback particle's mesh materials and scale, regardless of whether it's a custom particle effect or the default (unassigned) one.
     
    StevoFx likes this.
  24. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hey @StevoFx,

    The latest update to DestroyIt (1.14, live on the asset store now) includes the options you suggested. For any fallback particle effect (default or otherwise), you now have the choice of replacing the materials on the particle effect with the one from the destroyed object, not replacing them at all, or replacing each material with ones specified, as well as being able to scale the particle effect up or down as desired. Hopefully this graphic will help illustrate the options:



    Thanks for the suggestion, and hope that helps!
     
    StevoFx likes this.
  25. chuckyluv869

    chuckyluv869

    Joined:
    Sep 25, 2013
    Posts:
    42
    I am trying to get this to work with Ultimate Character Controller and I'm using a magic item that spawns a Magic Projectile and the DamageOnImpact script doesn't seem to work for this use case. The MagicProjectile.cs script has a public class "MagicProjectile : TrajectoryObject' instead of a "Projectile : Destructible" public class and that may be where to look for modifying the code to look for applying damage. I'm not a coder though so could you modify the DamageOnImpact.cs script to enable damage from Magic Items/Magic Projectiles?
     
  26. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hi @chuckyluv869,

    Yes, we can take a look at it and see what it would take to make the MagicProjectile.cs script work with DestroyIt. Can you send us a link to your project, uploaded to a cloud hosting site (Dropbox, Google Drive, OneDrive, etc)? Please email to modelsharkstudio@gmail.com.

    Also, please let us know in the email any instructions for how to reproduce the situation (instructions for firing the magic projectile and where in the scene it doesn't destroy a Destructible object) What scene in your project to run, any special instructions for switching to the magic projectile, etc. Thanks!
     
    Last edited: May 3, 2021
  27. hoschi3d

    hoschi3d

    Joined:
    Oct 4, 2014
    Posts:
    13
    zangad likes this.
  28. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hi @hoschi3d,

    We've reached out to the developer of NeoFPS to request a voucher trade so we can take a look at integrating DestroyIt with NeoFPS.

    Is there something specific you're trying to do with destruction in NeoFPS, or are you just needing to know in general how to make the guns/grendades/etc damage DestroyIt objects?
     
    hoschi3d likes this.
  29. chuckyluv869

    chuckyluv869

    Joined:
    Sep 25, 2013
    Posts:
    42
    Thanks! I sent the email with link to a test project for you to use.
     
  30. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Thanks @chuckyluv869,

    I took a look at your project and found a way to get the effect I think you're looking for without any code changes. Below are the step-by-step instructions, and also a video that covers how to make the change and what I look for when troubleshooting, so hopefully that helps.

    Also - nice looking character and magic particle effects, it's looking really good!

    How to Make Your Particle Effect do Damage to Destructible Objects:
    For your magic projectile, it's using a prefab Fireball_Small_01_Collision and that's where you need to make the change.
    1) Remove the Explosive_Force_01.cs script
    2) Add the \Assets\DestroyIt\Demos (safe to delete)\Scripts\Effects\Explode.cs script



    Video:
     
  31. chuckyluv869

    chuckyluv869

    Joined:
    Sep 25, 2013
    Posts:
    42
    Thanks for the kinds words!

    Unfortunately that solution won't work for my use case. I'm not able to exclude what the Explode script applies damage to. I tried that as a solution first. I'm sorry I didn't mention that. The Magic Item, like the other UCC scripts allow you to ignore layers so that when I throw a Magic Item it will hit and affect damage to the selected layers and that's why I wanted to get a script that uses the damage from the UCC scripts.

    I use the Explosive Force script to move rigid bodies around as part of the impact blast. I can tweak that to be different than a damage radius and ideally I will be able to use a script you supply to call the UCC damage to apply to DestroyIt! objects and the UCC script will exclude specific layers (using the Detect Layers variable) such as the Character and Sub Character Layer.
     
    Last edited: May 7, 2021
  32. chuckyluv869

    chuckyluv869

    Joined:
    Sep 25, 2013
    Posts:
    42
    I think I found a solution!!! Opsive UCC also has an Explosion script that allows for layer selection. That will work for my use case. So, I basically followed your instructions but used the Explosion.cs script from Opsive rather than the Explode.cs script. The only caveat I found in my testing so far is that damage will not be applied to a DestroyIt object unless it has both a collider and the Destructible script on the same game object and not separated as a parent or child game object.
     
  33. chuckyluv869

    chuckyluv869

    Joined:
    Sep 25, 2013
    Posts:
    42
    Do you HDRP versions of the materials available? Once I updated my materials in my project to get rid of the pink, the Progressive Damage feature stopped working. If I remember correctly, that's done through modifying the material properties.
     
  34. hoschi3d

    hoschi3d

    Joined:
    Oct 4, 2014
    Posts:
    13
    Hi
    Is it possible to somehow increase the time how long the destroyed parts are displayed?

    destroyit.jpg
     
  35. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    @chuckyluv869,

    Currently, no, progressive damage textures in DestroyIt are not supported for HDRP. Unity changed the HDRP shader to where the Secondary Detail Map albedo and normal are channel-packed into one image along with the metallic and occlusion maps. (For more details: https://docs.unity3d.com/Packages/c...ition@7.1/manual/Mask-Map-and-Detail-Map.html)

    So, since we use the secondary detail maps for progressive damage (the maps are swapped at runtime as the object gets damaged), we would have to unpack HDRP's channel-packed grayscale image, swap out part of it, save that as a new image, and assign it as the detail map again. We may try to do it this way, but the concern is: 1) how performant would that process be, and 2) the progressive damage texture would still have to share the same UV as the metallic and occlusion maps, which is not ideal.

    Another way we are looking at handling progressive damage for HDRP is by using Decals. So, we have some ideas in the works, but at the moment, no, progressive damage is only supported for the Standard Shader, Mobile Shader, and URP (via included custom URP shaders).

    EDIT - Oh, one other way to get progressive damage shaders to work for HDRP is to create your own HDRP shader with Shader Graph (or code) and expose three shader properties: _DetailMask, _DetailAlbedoMap, and _DetailNormalMap. In your graph, you would need to overlay those images on top of the albedo and normal outputs. DestroyIt will automatically show visible damage effects on any shader that exposes (and uses) those three properties.

    Now, I don't currently know how to duplicate the HDRP shader easily (and if you could, it would probably get outdated quickly, with so many changes going on). But I mention it because who knows - in the future there may be a way to easily duplicate the HDRP shader and add a couple properties to it through Shader Graph.
     
    Last edited: May 8, 2021
  36. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hi @hoschi3d,

    Yes, you can change how long the destroyed particles are displayed. The debris pieces in your screenshot are from a standard Shuriken particle system we created called DefaultLargeParticle. Here are the steps for how to make the pieces display longer:

    1) Locate your particle effect. For the chip-away debris column in your screenshot, it doesn't use a specific fallback particle for the destroyed pieces, so it uses the DefaultLargeParticle. Find the prefab under DestroyIt\Resources\Default_Particles and drag it into your scene.

    2) Click on the DefaultLargeParticle game object in your scene hierarchy and find the PoolAfter script. This script puts the particle effect back into the object pool after a specified number of seconds. Change the seconds to whatever you like (I'm changing it to 10):


    3) Click on the Large Pieces game object under the parent particle effect. This is a child particle system that spawns the larger debris chunks. Change the Start Lifetime to whatever you prefer. This tells the Large Pieces particle effect how long to live.


    4) Do the same for the Small Pieces.


    5) Once you are done making changes to the particle effect, select the parent (DefaultLargeParticle gameobject) again and click Overrides => Apply All to apply your changes back to the prefab.


    That's it! Now the pieces from that particle effect will persist in the scene for 10 seconds (with my changes, above) and will be re-pooled after that. Hope that helps!
     
    hoschi3d likes this.
  37. hoschi3d

    hoschi3d

    Joined:
    Oct 4, 2014
    Posts:
    13
    Thanks!
     
  38. chuckyluv869

    chuckyluv869

    Joined:
    Sep 25, 2013
    Posts:
    42
    Thanks for those details that should help me solve the issue. I've spent quite a bit of time in shader graph and I think I could develop that. If/when I do, I'll send you a working prefab with the custom shader graph. What I'm not sure about is how to display different levels of custom damage and have that be called by DestroyIt. In other words, I'll be modifying those properties you listed, I'll overlay them over the albedo and normal outputs, but how will I call the different levels of the damage detail map? I see 10 levels of that DetailMask1_D0 through DetailMask1_D9)?
     
  39. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    @chuckyluv869 - Oh, you don't have to worry about how to call it or anything. All you need to do is make your shader with those properties, and on the material that uses that shader:
    1) Assign the DetailMask1_D0 (solid black) texture to the _DetailMask property
    2) Assign your favorite damage albedo texture to the _DetailAlbedoMap property
    3) Assign your favorite damage normal map texture to the _DetailNormalMap property
    ...and DestroyIt does the rest. When the object takes damage, it will swap out the DetailMask automatically, depending on how many hitpoints the object has, how many damage levels, what percentage damaged it is, etc.

    Example of texture assignment on the material:


    There is code in DestroyIt that looks for these three properties, and if it has them and they have textures assigned, then it does the texture swapping.

    Code in DestroyIt that determines if the material is "Progressive Damage Capable":


    In fact, all I did to create the URP progressive damage shaders is just exposed those three properties and overlaid them in shadergraph to get the proper effect. The bulk of the work was recreating the URP shader in Shader Graph that has all the features of the built-in Unity URP shader. That was no small task - I basically built the shader from the ground up, adding every feature from the built-in shader, which is why it took a while to accomplish.

    So if you know of an easier way to recreate or copy the built-in HDRP shader into shader graph, then all that would need to be done is add those three properties and make them work in the shader. And that last part has already been done in the URP shader - take a look at the \DestroyIt\Shaders\DestroyIt_URP_PBR (and Transparent version) and in there you will see the properties and how it uses the two subgraphs (DestroyIt_ProgDamage_Albedo and DestroyIt_ProgDamage_Normal) to handle all the heavy lifting.

    The only promising thing I've seen on how to recreate the HDRP built-in shader in shader graph was an older github repo that had a version of it in shader graph, but I'd be concerned about how out-dated it was.
     
    Last edited: May 9, 2021
  40. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hi @entropicjoey1 ,

    No, DestroyIt doesn't include any state saving/loading mechanisms. For that, I would look for a dedicated game object state saving/serialization asset, such as:
    ProtoSave (https://assetstore.unity.com/packages/tools/integration/protosave-109069)
    EasySave (https://assetstore.unity.com/packag...he-complete-save-data-serialization-asset-768)

    Note that I don't have experience with these assets, just trying to point you in the right direction. There are a lot of data saving and serialization assets on the Unity Asset store, and anything that will work with game object data (transform position, scale, etc) and script properties (current hit points on Destructible script, etc) should work fine.

    For destructible terrain trees, DestroyIt strips off all non-critical scripts before placing the tree gameobject stand-ins in the scene, for performance reasons. This means any script/component that's not white-listed will get removed.

    So in order to keep a script on the terrain tree at runtime, you need to add the script to the whitelist code in the TreeManager.cs script:

    TreeManager.cs


    Here, we're just adding a line of code that tells DestroyIt not to strip off any WhenDamaged.cs scripts. You can add more lines to this code to whitelist any other scripts (such as WhenDestroyed or WhenRepaired). Keep in mind, if you have thousands of trees, each additional script on each tree will add up quickly and reduce performance. By the way, the events are always firing from the terrain trees, it's just that the scripts that were listening to those events were being removed.

    Oh, and if it's not working after making this code change, be sure that your tree prototypes have been updated to include the WhenDamaged script you added previously, by click the UpdateTrees button on your TreeManager component in the scene (at design time):



    A sure-fire way to tell if your script got removed from the terrain trees is to look in your scene view when the game is running (in the editor) and expand Environment and look for your tree game object clones. Click on one of those and inspect it to see if you see your script (for example, WhenDamaged). If you don't see it, then either it is getting stripped off because it is not "white listed" in the code (above) or your tree prototypes have not been updated on the terrain by clicking Update Trees (above).

    Hope that helps, let me know if you're still having issues!
     
    Last edited: May 13, 2021
    entropicjoey1 likes this.
  41. entropicjoey1

    entropicjoey1

    Joined:
    Jun 1, 2014
    Posts:
    24
    Thank you so much that makes perfect sense, i appreciate the support and information, =]]
    edit> works perfect and now i get resources to inventory when chopping down trees, sweet ^^
     
    Last edited: May 13, 2021
  42. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    216
    I haven't touch DestroyIt with Opsive UCC in a while and Opsive recently updated to version 2.3.2. I was wondering if they previous integration posts are still working or out dated because of the UCC updates.
     
  43. hoschi3d

    hoschi3d

    Joined:
    Oct 4, 2014
    Posts:
    13
    Hi,
    I have a small problem in the interaction with RFPS. (Realistic FPS Prefab) If I fire the weapon at the objects, everything works as it should and the object is destroyed. If I use hand grenades then nothing happens and the objects get no damage. At first I thought it was a problem with RFPS, but when I use the hand grenades against enemies, they are killed without a problem.
     
  44. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hey @hoschi3d,

    I also own the Realistic FPS Prefab asset, so I'll try to setup a test project on my end with both DestroyIt and RFPS and see if I can figure out how to make the hand grenades destroy destructible objects. I'll let you know what I find.
     
    hoschi3d likes this.
  45. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    @hoschi3d,

    Here are the steps to get the grenade in Realistic FPS Prefab to work with DestroyIt.

    1) In your scene, click on Window => DestroyIt => Setup - Minimal from the top menu in the Unity editor if you have not already setup DestroyIt in your scene.
    2) Add the section of code (below) to the \Assets\RFPSP\Scripts\Objects\!Destructibles\ExplosiveObject.cs script, at the line numbers illustrated in the screenshot.

    Code to add to ExplosiveObject.cs:
    Code (CSharp):
    1. }else if (hitCollider.gameObject.GetComponentInParent<DestroyIt.Destructible>()) {
    2.     hitCollider.gameObject.GetComponentInParent<DestroyIt.Destructible>().ApplyDamage(new DestroyIt.ExplosiveDamage {
    3.         DamageAmount = explosionDamageAmt, BlastForce = blastForce*50, Position = myTransform.position, Radius = radius, UpwardModifier = 0f
    4.     });
    5. }
    Screenshot of where to add the code in ExplosiveObject.cs:


    Results (video):


    You can adjust the amount of blast force and damage done to DestroyIt Destructible objects in the highlighted section of code (above). For example, I multiplied the amount of blast force by 50x, because I thought it looked better with the DestroyIt prefabs. You can adjust to your liking.
     
    Last edited: May 20, 2021
    hoschi3d likes this.
  46. hoschi3d

    hoschi3d

    Joined:
    Oct 4, 2014
    Posts:
    13
    Works perfectly. Thanks a lot!
     
  47. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    68
    when i pulled in my destroyed object prefab, i use gravity on the rigid body for like a tree it will fall, but when that destroyed prefab falls it hits other pristine prefabs and does damage to them; is there a way to stop the destroyed prefab from injuring pristine destroyit prefabs?
     
  48. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    68
    @zangad

    When i destroy a pristine destroy it prefab it pulls in the destroyed prefab such as a tree pulls in a destroyed tree prefab. Now, on that destroyed prefab i have a rigid body. this rigid body does damage to destroyit objects that it touches - is there a way to prevent this?

    for instance currently i have a farm building with its own destroyit health pool of 1500.
    the wheat field is on top of the farm prefab (the field part) and each wheat piece has 1 health and when they are destroyed each wheat prefab pulls in the destroyed prefab object. The destroyed wheat prefab has many pieces to it and each piece/particle has a rigid body attached to it so that it falls to the ground.

    however when these pieces of wheat with the rigid bodies attached to them touch the farm prefab while falling they will instantly do 700-800 damage to the farm. therefore destroying my farm in a matter of seconds if you destroy just 1 or 2 wheat prefabs.
     
  49. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    261
    Hi @moltke,

    I'm thinking the easiest way to do this would be if I added a new Tag to the TagIt script called "DontDoDamage" (or similar).

    So, for any object or prefab that: (A) has a rigidbody and (B) you don't want to apply damage to Destructible objects, you would drop the TagIt script on it and select the DontDoDamage tag. That would be all you would need to do. So in your case, you would add the TagIt script to your wheat pieces prefabs and select the DontDoDamage tag, and your wheat pieces would not do damage to any Destructible objects no matter how hard they collide with them.

    On my end, I will also need to modify the DestroyIt code to look for that tag when an object collides with a Destructible object, and ignore the collision if it has the DontDoDamage tag.

    Does that sound like it would work for you? If so, let me know and I'll add the feature and send you the code files to replace in your project.
     
  50. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    68
    That would totally make sense and i could apply it to ally my destroyed tree, rock and wheat prefabs so they dont damage stuff around them
     
unityunity