Search Unity

[Released] DestroyIt - Cinematic Destruction System

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

  1. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    There's no specific documentation for any one particular demo scene object, but I might be able to help. What are you trying to do?
     
  2. bearlike

    bearlike

    Joined:
    Mar 11, 2016
    Posts:
    6
    Hi, I saw a nuke effect in your video, but I can't find the nuke effect in the web demo. If I buy this asset, would it have the nuke effect?
     
  3. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    Yes, the nuke is included in DestroyIt. I'm not sure why we removed it from the web demo, but it is part of the package.
     
  4. Salja

    Salja

    Joined:
    Mar 23, 2017
    Posts:
    353

    Attached Files:

    Last edited: Apr 1, 2019
    tosvus likes this.
  5. Salja

    Salja

    Joined:
    Mar 23, 2017
    Posts:
    353
    Hey, i get a error if i create a build some ideas ?

    Screenshot_2.png
     
  6. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    Delete the "Extras (safe to delete)" folder and its contents. Those files are only for DestroyIt-Ready objects and aren't intended to be part of a final build.
     
  7. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    We're just starting to test DestroyIt with Unity 2019.1, but if you try it out yourself and get the following compiler error:

    D:/Workspace/DestroyIt - Collab/Library/PackageCache/com.unity.textmeshpro@2.0.0/Scripts/Runtime/TMPro_UGUI_Private.cs(2028,130): error CS1644: Feature `out variable declaration' cannot be used because it is not part of the C# 4.0 language specification​

    ...change your Scripting Runtime Version to .NET 4.x Equivalent.

    Edit --> Project Settings --> Player --> Other Settings (Configuration).

    You'll need to restart the editor when it asks you to.
     
    tosvus and DragonmoN like this.
  8. tosvus

    tosvus

    Joined:
    Dec 27, 2016
    Posts:
    44
    Hi, how accurate is it possible to be when destroying with say a sword? (think slicing like in fruit ninja, I suppose). Thanks!
     
  9. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    It's not a mesh-slicing system. You provide the destructible prefab (either mesh or particles or both) in advance.
     
  10. tosvus

    tosvus

    Joined:
    Dec 27, 2016
    Posts:
    44
    Ok, thanks!
     
  11. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    Someone on Youtube asked if DestroyIt worked with the HD Rendering Pipeline, and I thought I'd post the answer here in case anyone else wanted to know the answer.
    DestroyIt works with the HDRP system, but progressive damage doesn't work, and the HDRP system doesn't have any particle shaders yet, so destroying anything into particles causes pink boxes to appear. If you have a workaround for HDRP particle shaders (and terrain shaders, which were also pink after the conversion), the steps for converting are here: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@6.7/manual/Upgrading-To-HDRP.html
    Once HDRP is integrated into Unity officially (not a Preview version), we'll look at making progressive damage work for it.
     
  12. Michael2D

    Michael2D

    Joined:
    Mar 5, 2014
    Posts:
    17
    Hi
    Could you help me to make this work on MFPS?

    I have no idea how to set up damage system there.. To objects

    Thank you
     
  13. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    We've contacted Lovatto Studio for a voucher for MFPS. We'll let you know if they get back to us.
     
    julianr likes this.
  14. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    OK, they got back to us with a voucher, so we'll take a look at it as soon as we can.
     
  15. Michael2D

    Michael2D

    Joined:
    Mar 5, 2014
    Posts:
    17
    Thank you very much!
     
  16. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    UPDATE: If you are using MFPS 1.9 or above, please use the updated instructions here:
    https://forum.unity.com/threads/rel...estruction-system.251622/page-15#post-7976019

    Here is a step-by-step guide to using DestroyIt with MFPS 2.0 for multiplayer destruction.

    (1) Import MFPS 2.0 Multiplayer FPS
    (2) Open the \MFPS\Scenes\ExampleLevel scene
    (3) Import Photon PUN 2 (Free)
    (4) Login to Photon Cloud, setup a new Photon PUN project, and copy the AppId into the PUN Wizard

    (5) Import DestroyIt
    (6) From the top menu, choose Window => DestroyIt => Setup - Minimal

    (7) From the \DestroyIt\Demos (safe to delete)\Prefabs\Destructible Objects\Pristine folder, drag the Column prefab into the ExampleLevel scene

    (8) Select the Column game object in the Hierarchy and choose Add Component => Photon View
    (9) Drag the Column game object to the Observed Components field, and check the Synchronize Position and Rotation checkboxes on the Photon Transform View component

    (10) Open the \DestroyIt\Scripts\Behaviors\Destructible.cs script and add the [Photon.Pun.PunRPC] attribute to the ApplyDamage method
    Destructible.cs

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

    (12) Save all your changes to the scripts and the ExampleLevel scene

    Note: The instructions provided below are if you want to test multiplayer destruction in your scene with another developer. Each developer on your team will need MFPS 2.0 and DestroyIt and have them imported into the project as outlined in steps 1-5 above.

    (13) Export your changes into an asset package. 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.
    (14) Have your developer friend delete his/her ExampleLevel scene, and import your package so you are both running the same code.
    (15) 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.
    (16) From the in-game menu, create a new server and Join. Your friend should join the other side. Now when either of you damage or destroy the destructible column with a bullet, you will each see progressive damage and the particle effect.



    From here, you could expand your damage checking to knife cuts or grenades/molotov cocktails, so those also damage DestroyIt destructible objects. You could also try using a more advanced destructible object, one 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 or not. 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
    Fibonaccov likes this.
  17. Michael2D

    Michael2D

    Joined:
    Mar 5, 2014
    Posts:
    17




    Thank you so much! Everything is working perfectly. I already made thesystem to damage/kill player from big buildings. Your system is just perfect for destruction.

    Thank you again.

    Iam definitely going to buy this package again to support you!
     
  18. prolixe

    prolixe

    Joined:
    Jun 27, 2018
    Posts:
    11
    Hello,

    I'm making a FPS whit MFPS, so whit photon,and i'm using Unity 2019.2.8f1 HDRP and Destroyit 1.10.1

    All working well whit the HDRP ..

    Just put all your materials whit standard shader
    and
    in Edit - Render Pipeline - Upgrade project material to hight definition .

    You need to reworking the transparent materials using unlit for transparent or using Alpha Clipping for material decal and it's good..

    well..
    I have made some destructible objects, some barrel, glass, light etc..they're working ..

    Where i get a serious problem it is when the match is finished and coming the reloading of the map,
    In using MFPS we using Photon and the map is reloading each time the game is finished but more quickly ..
    Its Deathmatch CTF TDM Game when the map is reloading i need the destructed objects are back to they're initial state

    I can't find how to do it .. I tryed pooling but not working they just disseaper, i tryed whit SpawnObject and cant do it
    they are destroyed but they are not back when the game is finished and when the map is reloaded they are again destructed..

    Have you a solution for this one ?

    Thank you !
     
  19. zangad

    zangad

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

    In the demo scene we provide with the Unity package, we are reloading the scene when you press 'R', and also when you switch scenes - for instance when you go to the SUV Showcase scene and then back to the Main Scenarios scene.

    The scene switching just does a simple LoadScene operation, and the destructible object are all reset back to their original states:
    Code (CSharp):
    1. SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    Are you using a different method to reload your scenes? Because it seems like reloading the scene as you mentioned should reset the destructible objects fine.
     
  20. prolixe

    prolixe

    Joined:
    Jun 27, 2018
    Posts:
    11
    The reset R it is what i searched for add it in the relaunch yup..

    The coding is not my best part.. i'm better to map making.. : )

    I find this.. but i don't know if that the cause of not reloading ..i'm looking for now ..

    Code (CSharp):
    1.     public static void LoadLevel(string scene)
    2.     {
    3.         SceneManager.LoadSceneAsync(scene, LoadSceneMode.Single);
    4.     }
    5.  
    6.     public static void LoadLevel(int scene)
    7.     {
    8.         SceneManager.LoadSceneAsync(scene, LoadSceneMode.Single);
    9.     }
    Maybe its because its loaded Async ?

    Thank you for the quick responding !
     
  21. prolixe

    prolixe

    Joined:
    Jun 27, 2018
    Posts:
    11
    Maybe because the endif at start..

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. #if UNITY_EDITOR
    4. using UnityEditor;
    5. #endif
    6. using UnityEngine.SceneManagement;
    7. #if UNITY_EDITOR && UNITY_EDITOR_WIN
    8. using System.IO;
    9. #endif
    10. using Photon.Pun;
    11. using Photon.Realtime;
    12.  
    13. public class bl_UtilityHelper
    14. {
    15.  
    16.     public static void LoadLevel(string scene)
    17.     {
    18.         SceneManager.LoadSceneAsync(scene, LoadSceneMode.Single);
    19.     }
    20.  
    21.     public static void LoadLevel(int scene)
    22.     {
    23.         SceneManager.LoadSceneAsync(scene, LoadSceneMode.Single);
    24.     }
     
  22. prolixe

    prolixe

    Joined:
    Jun 27, 2018
    Posts:
    11
    In PhotonPunClass i find this :

    Code (CSharp):
    1.  - 916 -
    2.  
    3.   public class SceneManagerHelper
    4.     {
    5.         public static string ActiveSceneName
    6.         {
    7.             get
    8.             {
    9.                 Scene s = SceneManager.GetActiveScene();
    10.                 return s.name;
    11.              
    12.             }
    13.         }
    14.  
    15.         public static int ActiveSceneBuildIndex
    16.         {
    17.             get { return SceneManager.GetActiveScene().buildIndex; }
    18.         }
    19.  
    20.  
    21.         #if UNITY_EDITOR
    22.         /// <summary>In Editor, we can access the active scene's name.</summary>
    23.         public static string EditorActiveSceneName
    24.         {
    25.             get { return SceneManager.GetActiveScene().name; }
    26.         }
    27.         #endif
    28.     }
    29.  
    30. - 941 -
    Bha idk where to put your code ..For now i can't help myself x ) but it look photon using method for loading scene and mfps using method from photon .. its out of my skill : )
     
  23. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    @prolixie,

    Thank you for providing extra details regarding the issue you're having.

    We'll try to setup a similar scenario using MFPS and Photon PUN and go through the Deathmatch CTF TDM game (if possible), and see if we can reproduce the issue when the map reloads. Hopefully we'll have additional info or a solution for you soon.

    In the meantime, if you think of any addition details that would help us quickly setup a scenario to reproduce the issue, please let us know. We have MFPS, Photon PUN, and DestroyIt, so we should be able to setup a similar test scenario.
     
  24. prolixe

    prolixe

    Joined:
    Jun 27, 2018
    Posts:
    11
    Hello !
    For reproduce it just :
    Add destructible object in example map.
    Make a server whit select "Game per round"
    Launch the game, destruct the objet wait the round is finish : )

    I find this in bl_RoundTime :

    Code (CSharp):
    1.     public void StartNewRoundAndKeepData()
    2.     {
    3.      
    4.         GetTime(true);
    5.         isFinish = false;
    6.         if (RoomMenu != null)
    7.         {
    8.             RoomMenu.isFinish = false;
    9.             RoomMenu.isPlaying = false;
    10.             bl_UtilityHelper.LockCursor(false);
    11.         }
    12.         m_Manager.SpawnPlayer(PhotonNetwork.LocalPlayer.GetPlayerTeam());
    13.        
    14.     }
    Hope you will get a better result of mine..

    Thank you
     
    Last edited: Oct 18, 2019
  25. zangad

    zangad

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

    Thanks for the extra details regarding reproducing the issue, it helped me a lot. First off, a couple of things I discovered while working on this issue:

    1) The StartNewRoundAndKeepData() method doesn't seem to be used at all. I couldn't find any code references to it, and when I put a breakpoint in the method, it was never hit. So I'm not sure what that method is for, but it doesn't seem to be used.

    2) What is used to reset the scene is bl_RoomSettings.ResetRoom(). The way it is setup, though, it only resets player and score data for PUN - it doesn't actually reload the scene. That's why the destructible objects are never reset. Not reloading the scene means your levels can only ever have static (non-modifiable) objects in them. Optionally, you could programmatically add the objects to your scene, but that would be fairly tedious and require more programming.

    3) However, I found a place where you can reload the scene that seems to work: right before resetting the room. Now, I don't know if this is the preferred method for resetting a level in MFPS, but I'll share my changes in the hopes that it will at least get you past where you're stuck.

    NOTE: I would advise contacting Lovatto Studio and asking them what is the best way to reload a dynamic (non-static) scene with MFPS 2.0. Be sure to mention that you are removing objects from the scene and need to reload the scene after a match in order to reset everything. They should be able to tell you the best way to do that for their asset.

    Having said that, here's what worked for me:

    1) Open the bl_RoundTime.cs script. Paste this using statement at the top:
    Code (CSharp):
    1. using UnityEngine.SceneManagement;
    2) In bl_RoundTime.cs, scroll down to the FinishGame() method. Look for the line that says "if (RoomSettings)". Change that section of code to this:
    Code (CSharp):
    1. if (RoomSettings)
    2. {
    3.     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    4.     RoomSettings.ResetRoom();
    5. }
    Essentially, all we are doing is adding the code to reload the scene before it resets the room. But once I did that, things started working. Here a video of me running through the Game Per Round mode and destroying the destructible column a couple of times:

     
  26. prolixe

    prolixe

    Joined:
    Jun 27, 2018
    Posts:
    11
    Hello Zangad,

    Well..Thank you a lot for this one !
    If you are ok i'll share this in the Mfps forum in hope you will get some news customers : )
    I tryed your method and its working well, for showing correctly the stats in the finished screen i put the load scene after the reset setting
    Thank you a lot for the support, and the time.

    Code (CSharp):
    1.   GetTime(true);
    2.             if (RoomSettings)
    3.             {              
    4.                 RoomSettings.ResetRoom();
    5.                 SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    6.             }
    7.             isFinish = false;
     
    zangad and DeadlyAccurate like this.
  27. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    Absolutely! Thanks, and we're glad everything is working for you!
     
  28. Moe-Mogare

    Moe-Mogare

    Joined:
    Apr 16, 2015
    Posts:
    19
    is there a list of integrations for DestroyIt
     
  29. DeadlyAccurate

    DeadlyAccurate

    Joined:
    Apr 2, 2013
    Posts:
    186
    There's no specific list. Many of the first person controller assets have integration code. Was there a specific asset you were wondering about?
     
  30. hothead-brusnell

    hothead-brusnell

    Joined:
    Apr 15, 2014
    Posts:
    18
    Hi,

    Love the work you're doing here. Thank you.

    Question about the bundled "Chain Destruction Scene":

    When I destroy the lower wall (of the tall tower), the destruction chains it's way up to the top. This is great. That said, it doesn't look like gravity is applied correctly as the destruction chains up. Because of this, the upper sections of the tower appear to float before falling, breaking the overall effect.

    What is the recommended way of fixing this?

    Thanks!
     

    Attached Files:

  31. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Hi @hothead-brusnell,

    Thank you for the kind words. We really appreciate it.

    The chain destruction feature will also work with non-kinematic rigidbodies, we just didn't show it off in the bundled scene for some reason. A few simple tweaks to some variables and you should be good-to-go!

    Now, destruction effects are very subjective, but here's what I found that looked good to me:
    • For the bottom 3 floors, leave the Rigidbody component IsKinematic = true. This will give the structure stability.
    • For the top 3 rows of walls, set the Rigidbody component to IsKinematic = false.
    • For all the walls, change the ChainDestruction component Damage Per Second = 250. This will speed up the chain destruction effect overall.
    Video of the process and results:


    You can play around with different variables on each wall to tweak the speed of the chain destruction (Damage Per Second) and which walls have kinematic rigidbodies and which do not. This can be used to make cool crumbling effects, like an entire side of the tower that stays standing and is slowly damaged (low DPS number) while the rest of the walls crumble away.

    By the way, if you have problems with your walls swaying and falling apart after you make them non-kinematic, you can attach stiff joints to them so they don't start moving/falling until they no longer have supports. You might also want to increase the physics solver iterations so rigidbodies won't wiggle around too much and start moving on their own. The default is 6, which is pretty low. I've found that 20-30 for the solver iteration count gives me physics that behave as I expect, but of course that comes at the cost of performance, so you have to consider your target player's hardware.

    Hope that helps!
     
    Last edited: Apr 7, 2020
  32. hothead-brusnell

    hothead-brusnell

    Joined:
    Apr 15, 2014
    Posts:
    18
    This is great, thank you! If I have any further questions, I'll post back here. Thanks again!
     
  33. alexman

    alexman

    Joined:
    Jul 11, 2012
    Posts:
    17
    Hi,

    Thank you for the great asset, I've just purchased it and is learning how to use it.

    I'm having difficulty on making a damage texture on a tower game object, and I'm trying to find out why.

    Please find the video below where I am at the moment trying to use the material come with the basic scene and try to make the tower look damaged, but I couldn't

    The tower and the cube are basically identical just different mesh :



    Thanks in advance for your help.
     
  34. zangad

    zangad

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

    Please check the material on your tower. Are you using the exact same material as the cube (QuickStartMaterial-ProgDamage) or did you create your own? If you've created your own material, make sure you put it in the /Resources/Material_Preload folder. This way, the progressive damage system will know about the material and create the damaged variations for you. If it's not in that folder, you won't get any damage variations.

    If you're still having difficulty with it, then check your Tower material to make sure it has a Detail Mask (should be a black texture under /Resources/Material_Preload). Also under Secondary Textures, you should have a Detail Albedo and Normal Map. You can look at the QuickStartMaterial-ProgDamage material to see how your material should be wired up.

    Let me know if that doesn't fix it and I can take a look at your project.
     
  35. alexman

    alexman

    Joined:
    Jul 11, 2012
    Posts:
    17
    Hi @zangad ,

    Thanks for your quick reply !

    The cube and the tower use the same material, the QuickStartMaterial_ProDamage from the package, you can see in the video that I selected both game object and the material field is the same, that material is from the package and has detail map etc

    I have selected both game objects in the video so we can see basically they are exactly the same except using different mesh, the different is that only the cube has the crack

    Thanks again,
    Alex
     
  36. zangad

    zangad

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

    Please check your email, I responded to the email you sent us. From the screenshots you sent us, it looks like your model is using a very small part of the texture's UV. In this case, you will need to increase the X and Y tiling on the material's Secondary Map in order to see the crack details at the right size.

    Please let me know if that doesn't fix it.
     
  37. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    109
    Hello @zangad ,

    I think I've run into a glitch with Destroyit and Gena in groups, it works great with Gena if I spawn single Destroyit prefabs, but when I make a group of Destroyit prefabs the trees in the groups call in 3 Destroyed prefabs and they explode into the sky and all over.

    Here's the video explaining my problem

     
  38. zangad

    zangad

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

    Thanks for reaching out to us, and for the detailed video explanation of the issue you're having. I own Gena, but haven't used it beyond initial playing around. I haven't used the groups or Gena spawner features, so I'm not sure how they work on the backend.

    Would you be able to export your project as a unity package, upload to OneDrive/Dropbox/GoogleDrive/etc and send us a link to it (modelsharkstudio@gmail.com)? I suspect what's happening is when the Destructible object is destroyed and tries to locate the destroyed prefab in the object pool, something with the way Gena is grouping/linking the objects together is confusing the Destructible script that spawns in the destroyed prefab, and maybe it's spawning in one destroyed prefab for each object in the group, or something like that.

    I'd like to open the hierarchy during gameplay and see what game objects are in the object pool, both when using the Gena group spawner and when only spawning a single destructible object. Another thing I'd like to do is debug step through the ProcessDestruction() method in DestroyIt code to see if it's trying to spawn in multiple destroyed prefabs at that point. I could try to setup a scene like you have, but I might set it up differently than you did, plus I'm not very familiar with Gena in general, so if I can get a copy of your scene to work with, that would help me troubleshoot it a lot.
     
  39. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    109
    Sure I'm trying, Trying to export the package but not enough room on my disc and large project so having to choose what I need to send to you, I will get it done sometime today when the computer is done doing its thing.
     
  40. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    109

    Alright I've emailed you with the link to the dropbox with the unity prackage
     
  41. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Thank you! I'm setting up that version of Unity and taking a look at it now.
     
  42. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    @moltke,

    Ok, I think I found the issue. It looks like the extra destroyed prefabs and exploding trees were caused by duplicate destructible objects in the group.





    Please try deactivating the extra destructible trees and see if that fixes the problem for you.
     
  43. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    109

    So my prefab groups don't have those duplicates, but for some reason Gena is duplicating the prefab and making it so that two groups spawn at the same place.... hmmm weird... I wonder why that is. I guess I'll have to do more investigating, thank you for finding that
     
  44. ddesmond

    ddesmond

    Joined:
    Feb 9, 2010
    Posts:
    163
    @zangad , are you able to do create a digging effect, like digging into a wall effect. I was looking for a tunneling type of effect
     
  45. hoschi3d

    hoschi3d

    Joined:
    Oct 4, 2014
    Posts:
    17
    Hi, I have a small problem with the Realistic FPS Prefab. It works with the normal weapons as well as Melee, only with grenades there is no damage. Anyone have an idea what it could be?
     
  46. prolixe

    prolixe

    Joined:
    Jun 27, 2018
    Posts:
    11
    Hello,

    I get this error message on all destructible object whit the When destroyed play sound script :

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. DestroyIt.WhenDestroyedPlaySound.OnDisable () (at Assets/DestroyIt/Scripts/Behaviors/WhenDestroyedPlaySound.cs:25)
    3. UnityEngine.GameObject:SetActive(Boolean)
    4. DestroyIt.ObjectPool:poolObject(GameObject, Boolean) (at Assets/DestroyIt/Scripts/Managers/ObjectPool.cs:257)
    5. DestroyIt.ObjectPool:Start() (at Assets/DestroyIt/Scripts/Managers/ObjectPool.cs:75)
    6. DestroyIt.ObjectPool:get_Instance() (at Assets/DestroyIt/Scripts/Managers/ObjectPool.cs:39)
    7. DestroyIt.Destructible:Start() (at Assets/DestroyIt/Scripts/Behaviors/Destructible.cs:129)


    Do you have some fix for this or reason about ?

    Thank you !
     
  47. zangad

    zangad

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

    For some reason, we didn't get a notification about your post - sorry about the late response.

    I believe what you're looking for is a voxel deformation tool. DestroyIt doesn't do that, but I searched on the asset store and found a couple that seem like what you're looking for:

    https://assetstore.unity.com/packages/tools/terrain/digger-terrain-caves-overhangs-135178 (for terrain)
    https://assetstore.unity.com/packages/tools/modeling/voxel-generator-162883 (for meshes)
     
    Last edited: Apr 6, 2020
  48. zangad

    zangad

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

    I haven't been able to reproduce the issue you're having with the WhenDestroyedPlaySound.cs script. However, one thing you might try is adding an extra safety check with these instructions:

    1) Open the WhenDestroyedPlaySound.cs file in a text editor.
    2) Replace the entire OnDisable() method with this code:
    Code (CSharp):
    1. private void OnDisable()
    2. {
    3.     // Unregister the event listener when disabled/destroyed. Very important to prevent memory leaks due to orphaned event listeners!
    4.     if (destObj == null) return;
    5.     destObj.DestroyedEvent -= OnDestroyed;
    6. }
    3) Try again and see if you still get the error.

    The only thing I added was a check to see if the reference to the Destructible script was still intact. The only thing I could think of is maybe Photon PUN is affecting the order in which the events are fired, and by the time the OnDisable() event is fired, the object has already been destroyed and the Destructible script reference no longer exists.

    I hope this code change fixes the issue for you, but even if it does I would still be interested in more details about what actions caused this error so I can reproduce it myself.

    1) Are you getting the error as soon as you run the scene, or when the object is destroyed? From the callstack, it looks like you get it as soon as the scene starts.
    2) Are you getting this error when running the scene in the Unity editor, or when running the project as a build?
    3) What version of Unity and DestroyIt are you using?
    4) Do you get the error when not using Photon PUN?
    5) I noticed the destructible object is tagged as "Respawn". Are you using this for any particular reason, such as a respawn system? Do you get the error when the object is respawned?
    6) Can you expand the Destructible script in your screenshot so I can see how it's setup, to help me reproduce it on my end?
     
  49. prolixe

    prolixe

    Joined:
    Jun 27, 2018
    Posts:
    11
    Hello @zangad ,

    Well like alway... it's working :)

    1) Are you getting the error as soon as you run the scene, or when the object is destroyed? From the callstack, it looks like you get it as soon as the scene starts.

    I get this a soon as i running the scene.

    2) Are you getting this error when running the scene in the Unity editor, or when running the project as a build?

    I don't have console in my project when i build it so idk

    3) What version of Unity and DestroyIt are you using?

    Unity HDRP 2019.3.8f1 - DestroyIt 1.11 but it look i forget to update the latest

    4) Do you get the error when not using Photon PUN?

    idk

    5) I noticed the destructible object is tagged as "Respawn". Are you using this for any particular reason, such as a respawn system? Do you get the error when the object is respawned?

    Respawn tag was from previous testing i just forget to untag and you already fixed this problem : )

    6) Can you expand the Destructible script in your screenshot so I can see how it's setup, to help me reproduce it on my end?

    I can



    Thank you for this one !
     
  50. zangad

    zangad

    Joined:
    Nov 17, 2012
    Posts:
    357
    Thanks for the feedback, @prolixe.

    I didn't see anything unusual about your setup, so I'm still not sure why you got that error. But I'm glad it's fixed for you now, and I'll add that fix to all our code that un-registers events in the OnDisable() method, so no one gets the error going forward.