Search Unity

Exploder [RELEASED]

Discussion in 'Assets and Asset Store' started by reindeer-games, Jul 12, 2013.

  1. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    Hi, two questions:

    1. I noticed it has a dll file. Does this mean it requires Pro?


    2. Will it be difficult to retrofit this plugin to allow "slicing" meshes into two parts by a straight line? (instead of separating into small fragments)
     
  2. tequibo

    tequibo

    Joined:
    Jun 4, 2013
    Posts:
    19
    I have purchased this asset today, before this I used pre-fractured in blender meshes, so I am hoping it will save me some time in setting those up.
    After few hours I almost got it working the way I want to.

    So, the way my game set up is that once enemy dies I do this:

    Code (csharp):
    1. var objList = new List<GameObject>();
    2.         var objList1 = GetComponentsInChildren<MeshFilter>().Select(i => i.gameObject);
    3.         var objList2 = GetComponentsInChildren<SkinnedMeshRenderer>().Select(i => i.gameObject);
    4.         if (objList1.Count() != 0)
    5.             objList.AddRange(objList1);
    6.         if (objList2.Count() != 0)
    7.             objList.AddRange(objList2);
    8.         foreach (var destroyableObject in objList) {
    9.             destroyableObject.tag = Tags.exploder;
    10.             ExploderOption o = destroyableObject.AddComponent<ExploderOption>();
    11.             o.CrossSectionUV = new Vector4(0, 0, .01f, .01f);
    12.             //destroyableObject.transform.parent = null;
    13.  
    14.         }
    15.         exploder.TargetFragments = shards;
    16.         exploder.transform.position = position;
    17.         exploder.Explode();
    I assign tags at run time, so that if enemy dies nearby enemies meshes would not be affected. And I want to use the same mesh enemy have, so it would be oriented/animated same way, otherwise it would be almost the same as before.

    I works fine now for the most part, but I have two problems now.

    First - when enemies or objects get shattered by explosion - sometimes they break in a huge chunks, or even not break at all.
    I kind of solved it by adding delay between damage calls by explosion to objects. But in demo explosions seems to be working fine when "explode all" function called.

    Second problem sometime fragments dissapear, even though I set a huge fragment limit and there is no any deactiovation options.

    Is this because of some sort of optimization? Or am I doing something wrong?

    Thanks!
     
    Last edited: Nov 30, 2013
  3. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    1] No, it doesn't require Unity Pro. The dll is managed code, it is open source library for triangulation, you can freely download from https://code.google.com/p/poly2tri/.

    2] I am not sure if I understand you correctly, can you explain me more or make a picture?
     
  4. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello,

    thank you for purchasing the package!

    This error is related to GameObject/meshes marked as static. Exploder cannot explode static GameObject, because you simply cannot access the mesh of static GameObject. If you mark the game object as non-static, it should work fine. Anyway it shouldn't cause the error crash, the fix and warning to console will be in next update.
     
  5. tequibo

    tequibo

    Joined:
    Jun 4, 2013
    Posts:
    19
    I wonder it you missed my questions in a post above.
    I really would like to know what can be the reason for fragments to start dissapearing(or rather switching) when no deactivation opttions are used at around 50 total fragments when I set pool size to 1000, and how I can stop this.

    And why sometimes meshes get split in a huge chunks or not split at all, ignoring target fragments setting.
     
    Last edited: Nov 30, 2013
  6. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    I am really sorry I missed your old post.

    To answer your questions:

    Exploder explodes everything in the radius at specified position like a grenade. In the center you will get more fragments, far from center less and bigger fragments. And internally works as a queue, so if you run multiple explosions at the same time, it will run explosion one by one until the queue is empty. So it can happen that your enemy is moving, exploder runs first explosion several frames, than runs second explosion in the old enemy position but the enemy is already gone now. Can it be your case?

    Also if you explode only one object it is better to move exploder to the center of the object by provided method:

    Code (csharp):
    1.  
    2. // this will move exploder to the center of the object based on its render bounds
    3. Exploder.transform.position = ExploderUtils.GetCentroid(object);
    4.  
    It looks like a bug, I am just testing it in FPS demo and see the problem, I will post a fix here in a moment...
     
  7. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    This is a hot fix for disappearing fragments.

    Replace this code in Fragment.cs at line 150:

    Code (csharp):
    1.  
    2.         /// <summary>
    3.         /// deactivate this fragment piece
    4.         /// </summary>
    5.         public void Deactivate()
    6.         {
    7.             ExploderUtils.SetActive(gameObject, false);
    8.             visible = false;
    9.             activeObj = false;
    10.         }
    11.  
    12.         private Vector3 originalScale;
    13.         private float visibilityCheckTimer;
    14.         private float deactivateTimer;
    15.         public bool activeObj;
    16.  
    17.         void Start()
    18.         {
    19.             visibilityCheckTimer = 1.0f;
    20.             RefreshComponentsCache();
    21.             visible = false;
    22.         }
    23.  
    Add this code in FragmentPool.cs at line 80:

    Code (csharp):
    1.  
    2.             int counter = 0;
    3.  
    4.             // get deactivated fragments first
    5.             foreach (var fragment in pool)
    6.             {
    7.                 // get invisible fragments
    8.                 if (!fragment.activeObj)
    9.                 {
    10.                     fragments.Add(fragment);
    11.                     counter++;
    12.                 }
    13.  
    14.                 if (counter == size)
    15.                 {
    16.                     return fragments;
    17.                 }
    18.             }
    19.  
    This code will look first for deactivated fragments, after the fragment pool is full it starts to recycle old fragments, first not visible or sleeping etc. For more details look at the function:

    Code (csharp):
    1.  
    2. public List<Fragment> GetAvailableFragments(int size)
    3.  
    If you have any problems, let me know.
     
    Last edited: Nov 30, 2013
  8. tequibo

    tequibo

    Joined:
    Jun 4, 2013
    Posts:
    19
    Thanks for replying, good to know it will be fixed!

    Here, I made a gif demonstrating the problem on a not moving objects: http://i.minus.com/i4xs0JVjKGNc5.gif (removed projectile explosion effect to make it easier to see)

    Also, small thing, but it would be nice to have an option for adding angular velocity with random direction to fragments.
    I added a some quick code for this myself with, but I will have to add it again in case if I download updated version, so it would be nice to have.
     
    Last edited: Nov 30, 2013
  9. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Thank you for the fast response, in my case it was disabled read/write on mesh in importer.
     
  10. Thinice

    Thinice

    Joined:
    Jan 20, 2012
    Posts:
    35
    Hi! Wonderful plugin!! Works really great but I'm having some problems, maybe you can help?

    (I'm using UnityScript)

    I can call "Explode()" and it works great, everything is as expected. But since my game works in mobile, I prefer to crack the object beforehand.

    The problem is that if I try to call "Crack()" and then "ExplodeCracked()", nothing happens. I even setup a callback when calling "Crack()" but the callback function is never called. The "FragmentRoot" object is created and fragments are created under it, but no callback and no explosion neither :-(

    Any idea on what may be the problem here?

    Thanks a lot!
     
  11. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    thank you, I am not sure what the problem can be. How about the Explode() function, does it explode when you call it? I am not expert on UnityScript or JS, what I was using for communication between JS and C# was SendMessage and it was working well for simple functions but I am not really sure about callbacks. Could you please try to run Explode() to see if something get exploded at all, it might be also problem with Exploder position/radius or other parameters. I try to test cracking with JS, actually I never tested before. Also make sure that you have everything setup like in "DemoClickExplode.cs" where you can find example of cracking.
     
  12. Thinice

    Thinice

    Joined:
    Jan 20, 2012
    Posts:
    35
    Thanks for the quick reply!

    I've just tested and "Explode()" works great, as expected. I've even added a callback and it works great too (though the callback function gets called 2 times, but that may be something on my part...)

    So, calling "Crack()" effectively cracks the object BUT no callback, and "ExplodeCracked()" doesn't work afterwards either. :-(
     
  13. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I see now, it is correct behavior, you have specified some small number of target fragments and it breaks one object in many pieces and after shooting in the middle of many objects it doesn't split objects at all, only "kick" them away. It is because the exploder counts one object as one fragment, for example if you have specified 5 target fragments and you shoot into 5 objects, exploder finds those 5 objects in the radius and assign each object as one fragment and there is no more target fragments to process, so the calculation will stop. If you have 5 objects and 10 target fragments, it will create first 5 basic fragments and then it cut the closest objects into 5 other pieces.

    In FPS demo everything is exploded because the target fragments is high so usually everything get cut and exploded. But I understand that it might be a problem if you have specified low number of target fragments, we can change this, it should be an easy fix.


    Ok, good idea, I will add this.
     
    Last edited: Dec 1, 2013
  14. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Could you please paste here the code with ExplodeCracked with callback? Just the method signature, I will test it.

    And you see the callback 2 times - it is correct, first time it is called with state == ExplosionStarted, second time it is called with state == ExplosionFinished, you can find explanation in ExploderObject.cs on line 211 (public enum ExplosionState).
     
  15. Thinice

    Thinice

    Joined:
    Jan 20, 2012
    Posts:
    35
    I just use exploder.Crack() on Start() and exploder.ExplodeCracked() when I press a key.

    I actually don't need the callbacks, I was just testing why the ExplodeCracked() method didn't work and that's how I found that Crack(myFunction) was never calling "myFunction" after finished cracking.
     
  16. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I just converted ClickAndExplode.cs to UnityScript and cracking seems to be working fine. I just learned that I can call c# classes directly when I copy it to Assets/Standard Assets folder. Anyway here is the code, I am not sure if it helps you, also make sure that your script Crack() on Start() is called after the Exploder Start(), I had to adjust script execution order to make it work.

    Code (csharp):
    1.  
    2. #pragma strict
    3.  
    4. var Exploder : ExploderObject;
    5. var Camera : Camera;
    6. private var DestroyableObjects : GameObject[] = null;
    7.  
    8. function Start()
    9. {
    10.     // find all objects in the scene with tag "Exploder"
    11.     DestroyableObjects = GameObject.FindGameObjectsWithTag("Exploder");
    12. }
    13.  
    14. function IsExplodable(obj : GameObject)
    15. {
    16.     return obj.CompareTag(ExploderObject.Tag);
    17. }
    18.  
    19. function Update()
    20. {
    21.     // we hit the mouse button
    22.     if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))
    23.     {
    24.         var mouseRay : Ray;
    25.  
    26.         if (Camera)
    27.         {
    28.             mouseRay = Camera.ScreenPointToRay(Input.mousePosition);
    29.         }
    30.         else
    31.         {
    32.             mouseRay = UnityEngine.Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
    33.         }
    34.  
    35.         var hitInfo : RaycastHit;
    36.  
    37.         // we hit the object
    38.         if (Physics.Raycast(mouseRay, hitInfo))
    39.         {
    40.             var obj = hitInfo.collider.gameObject;
    41.  
    42.             // explode this object!
    43.             if (IsExplodable(obj))
    44.             {
    45.                 if (Input.GetMouseButtonDown(0))
    46.                 {
    47.                     CrackObject(obj);
    48.                 }
    49.                 else
    50.                 {
    51.                     ExplodeAfterCrack();
    52.                 }
    53.             }
    54.         }
    55.     }
    56. }
    57.  
    58. function CrackObject(obj : GameObject)
    59. {
    60.     // activate exploder
    61.     ExploderUtils.SetActive(Exploder.gameObject, true);
    62.  
    63.     // move exploder object to the same position
    64.     Exploder.transform.position = ExploderUtils.GetCentroid(obj);
    65.  
    66.     // decrease the radius so the exploder is not interfering other objects
    67.     Exploder.Radius = 1.0f;
    68.  
    69.     // crack
    70.     Exploder.Crack();
    71. }
    72.  
    73. function ExplodeAfterCrack()
    74. {
    75.     Exploder.ExplodeCracked();
    76. }
    77.  
    78. function OnGUI()
    79. {
    80.     if (GUI.Button(new Rect(10, 10, 100, 30), "Reset"))
    81.     {
    82.         if (!Exploder.DestroyOriginalObject)
    83.         {
    84.             for (var destroyableObject : GameObject in DestroyableObjects)
    85.             {
    86.                 destroyableObject.active = true;
    87.             }
    88.  
    89.             Exploder.active = true;
    90.         }
    91.     }
    92. }
    93.  
     
  17. tequibo

    tequibo

    Joined:
    Jun 4, 2013
    Posts:
    19
    I think I figured out what my problem is - it seems that I mark object meshes for object with exploder tag, then call explosion, but because of the queue, first all meshes marked for explosion, then first explosion goes, all objects shattered, and then other explosions execute.

    It would be nice to be able to just feed a list of objects to .Explode() function tbh.
    I will find some walkaround though.

    But still, neat plugin! Keep up good work!
     
  18. Thinice

    Thinice

    Joined:
    Jan 20, 2012
    Posts:
    35
    Ok I found my problem:

    I was calling "Crack()", then moving the exploder object to my desired position, and then calling "ExplodeCracked()". The problem was that when I called "Crack()", the object was not in range of the exploder object, so now I move the exploder before calling "Crack()" to make sure it's in range, and it works great!

    There is another problem I have now, and it can be experienced in your demo scene called "SceneClickExplode": if you click on the robot, the cracking occurs and later when you explode it the fragments appear where the robot was when it was cracked, not where the robot is right now. Is that easy fixable?

    Thanks again!

    Edit: Ok never mind, I just found that moving the "FragmentRoot" object to the desired position before cracking and then moving it again to the desired position before exploding does what I was looking for. :)
     
    Last edited: Dec 1, 2013
  19. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    Hi Reindeer, have been using exploder for a while now, has been working great, and thanks again for setting up the 'crack' feature.
    I have an issue that I'm not sure is my fault or not....
    Everything works fine until I re-load the level, then try to explode something.. (e.g. player dies so I call this....)
    Application.LoadLevel(Application.loadedLevel); //load this level again, re-start

    Then I get a bunch of Null reference errors from exploder... primarily timers
    I tried adding something like this...
    if (timer==null)
    timer = new(Stopwatch);
    but that just moved the errors to some other place.

    NullReferenceException: Object reference not set to an instance of an object
    ExploderObject.Postprocess (Int64 timeOffset) (at Assets/Exploder/Exploder/ExploderObject.cs:935)
    ExploderObject.Update () (at Assets/Exploder/Exploder/ExploderObject.cs:645)


    I also get this printing endlessly...

    MissingReferenceException: The object of type 'Fragment' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    Exploder.FragmentPool.SetExplodableFragments (Boolean explodable) (at Assets/Exploder/Exploder/FragmentPool.cs:244)
    ExploderObject.InitPostprocess () (at Assets/Exploder/Exploder/ExploderObject.cs:840)
    ExploderObject.Update () (at Assets/Exploder/Exploder/ExploderObject.cs:642)


    I also get

    Is there some special way I should shut down or destroy exploder before re-loading level ?

    This problem occurs regardless of wether I have exploded anything in the scene or not when I call LoadLevel.

    after first load =>everything cool
    after re-load same level => exploder broken.

    I have no idea how anything could possibly be different if I am re-loading the entire level, it should be the same...shouldn't it ?
    I got your plugin when it was initially launched (after adding crack), so maybe I should update to new version?
    Has anyone else seen this issue, or am I doing something silly ?

    thanks in advance
     
    Last edited: Dec 4, 2013
  20. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi JonnyHilly,

    you are not doing anything silly, this is an old bug and it was fixed a long time ago, shortly after that crack feature was introduced. If you update to the newest version it should be ok. There are not many changes in interface API from earliest versions, perhaps you will have to change callback parameters, otherwise it should be fine.

    Let me know if you have any problems.
     
  21. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    Awesome! Thanks much. :)
     
  22. JohnML

    JohnML

    Joined:
    May 24, 2013
    Posts:
    11
    Does Exploder work well with the new Unity 4.3 2D sprites, and Box2D implementation? If not, will it support it soon?
     
  23. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Unfortunately not, Unity4.3 sprites are not supported because there is no way to access the mesh data. I can support it only after Unity releases update and allows to access the sprite mesh, I saw already lots of people requested this feature...
     
  24. indy2005

    indy2005

    Joined:
    Aug 22, 2009
    Posts:
    81
    Hi,

    I am using 2d toolkit, with 2d physics. In Exploder, the fragments do not collide with 2D rigid bodies it seems, is there a way to enable this?

    Regards

    i
     
  25. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    no, currently there is no simple way to enable it, but I have plane to fix it to the next version ... (~1 week).
     
  26. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Anybody have experience using Exploder along with Pool Manager? (https://www.assetstore.unity3d.com/#/content/1010)

    I just discovered that when I use Explode on a GameObject that I've pooled, Pool Manager doesn't get the next one from the pool. When I comment out the Exploder explosion, the pooling works again. I've got my ExploderObject set to:

    ExplodeSelf: False
    Hide Self: False
    Destroy Original Object: False

    Any ideas?
     
  27. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Very cool!! I am loving this!

    Couple things I need help with.

    1. One object pops up into the air before it explodes. It's a statue that is sitting slightly embedded into terrain. Any way to prevent this besides possibly moving statue up to not be embedded into terrain?
    Update: I just moved statue above ground and it still pops up?

    2. I see the entire statue explode. I would like only the head to explode. Is this possible with 1 solid mesh?

    3. I have a wall that is one giant object. When my character rams into wall I would like only the area he bashes into to explode. Is this possible or do I need a ton of individual objects that make up a wall?

    This is such a cool package that I hope I can get to work in my mobile game. Great job!!
     
    Last edited: Dec 13, 2013
  28. tbg10101_

    tbg10101_

    Joined:
    Mar 13, 2011
    Posts:
    192
    Hey,

    I love this asset but I keep getting the following error while trying to explode some cubes:
    Assert! distance: 0.6331701 radius: 0.67
    UnityEngine.Debug:LogError(Object)
    ExploderUtils:Assert(Boolean, String) (at Assets/Exploder/Exploder/Utils/ExploderUtils.cs:21)
    ExploderObject:GetLevel(Single, Single) (at Assets/Exploder/Exploder/ExploderObject.cs:573)
    ExploderObject:GetMeshList() (at Assets/Exploder/Exploder/ExploderObject.cs:739)
    ExploderObject:preprocess() (at Assets/Exploder/Exploder/ExploderObject.cs:969)
    ExploderObject:Update() (at Assets/Exploder/Exploder/ExploderObject.cs:841)

    Any idea what is causing this?
     
  29. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    this is an old error, I apologize for this, it will be removed in the next update. Now you can simply ignore the assert by changing the
    debug condition in ExploderUtils.cs:

    ...
    [Conditional("UNITY_EDITOR")]
    public static void Assert(bool condition, string message)
    ...

    on line 16

    replace with

    [Conditional("UNITY_EDITOR_DEBUG")]

    ... And the assert will not be there anymore.

    Thanks I will fix it in the next version.

    Regards.
     
  30. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, thanks! I am not sure why you see the popping, does the statue have any colliders attached? Try to assign a box collider and rigid body (just for test) and make sure that the statue is not in collision with the terrain. But hard to say, if you have more problems, better send me a screenshot in PM.

    This is not possible, local destructions are not supported, you can only explode a whole game object. You can solve this problem by dividing head and body into two different game objects.

    This is similar to previous question, it is not possible with Exploder. Exploder is more suitable for destroying smaller objects, skinned meshes, etc. Not for destroying walls or buildings, however you can still solve this problem if you construct your wall from smaller game objects.

    Thanks! Exploder has a lots of settings and you can easily adjust parameters (target fragments, time budget for calculation, etc) to get better performance on mobiles and lots of people are already using Exploder on mobiles.
     
  31. mcconrad

    mcconrad

    Joined:
    Jul 16, 2013
    Posts:
    155
    hi, i got exploder a while back and only recently gotten to implement it into my game, but i am having a small problem that is likely very easy to fix. when my player explodes an object, it launches her even when the explosion force is set to an extremely small amount. how can i change it so that she either only receives a % of the force applied to the detonated object or not at all.

    btw yes i have mesh collisions on, and the force is set to 0.1 but still has quite a knockback to any rigidbodies in the area.
     
    Last edited: Dec 23, 2013
  32. bromske

    bromske

    Joined:
    Sep 11, 2012
    Posts:
    28
    hello, one little question...
    i've a lot of same gameobjects on the screen, can i crack one, and use the fragmented gameobject as prefab or so, for my other gameobjects too?
     
  33. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    you cannot, Exploder is only for real-time use. There is no simple way to create prefabs from cracked object.
     
  34. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I am really not sure, why you seeing the knockback. The lowest possible settings is using mesh colliders (True) and set Force to 0.0. Maybe a video or a few screenshots would be helpful, you can send it to my PM.

    Thanks.
     
  35. n8

    n8

    Joined:
    Mar 4, 2010
    Posts:
    147
    I have quickly read through the forum, but haven't seen anything. Has anybody had success/failure trying to implement this asset with objects created by the probuilder asset? Also is there any stats from using this on iOS? Thanks!
     
  36. cranecam

    cranecam

    Joined:
    Nov 25, 2013
    Posts:
    25
    Hi,
    My cube has 2 materials, during explosion it drops both...is this expected? any particular shader recommended?
     
  37. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Just a follow up, on the off chance that anyone else runs into this. Exploder sets the original object to inactive during Explode(), and I had a timed despawn set up so that despawning my original object didn't happen until a fraction of a second after the explosion. So the timed despawn code never had a chance to fire. I didn't really need that delay, so I just changed the logic to immediately despawn and that fixed it. Whew!
     
  38. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello guys,

    a new version 1.2 is finally on the asset store!

    Main features:

    • 2D Physics support (Unity 4.3 + 2D Toolkit)
      • Enable 2D Physics with PolygonCollider2D
      • Tested with 2D Toolkit
    • Playmaker support
      • 3 custom Playmaker actions (Explode, Crack, ExplodeCracked)
    • Bugfixes

    [video=youtube_share;IZWz5mt2kIY]http://youtu.be/IZWz5mt2kIY
     
  39. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    Hi
    quick question... I sometimes need to delete the fragments manually at a time of my choosing. But I then get null ref errors from exploderPool
    Is there a way to find fragment component on a gameObject and tell it to gracefully remove itself from lists to avoid those null ref errors?
     
    Last edited: Jan 18, 2014
  40. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    I'm using it on iOS, performance seems good so far, tested on iPhone5 and iPad3, breaking 4 or 5 cubes into about 10 pieces each at the same time.
     
  41. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    302
    Hi

    Thank you for a very fun asset :D love it.

    I'm experiencing some very strange behavior, i cant really explain it so i recorded it on video.

    But what happens is, i have a block marked as enemy, with the exploder object on it and it is pre-cracked
    also have a normal cube with the exploder object on it also pre cracked.

    But when i destroy the cube it always destroys the other (enemy) aswell, and when i destroy the enemy
    i get explosions over at the cube, but the cube remains intact.

    Also it only works for 2 objects, even though im using deactive over time, and set it very low
    i can only explode maybe 2-3 items and then nothing else.

    The video - not commented -
    First I'm browsing through all the objects
    Then i show the playMaker setup
    And then finally i play and show what happens.

    Sorry for the weird transistions in the video, but I'm on multimonitor (3) soe it would be hard to see
    on youtube's low resolution.

    [video=youtube_share;dpSNAu2p0MI]http://youtu.be/dpSNAu2p0MI

    Any ideas what's going on here?

    Edit : Partial solved the issue.
    When i stopped using "cracked" on my prefabs it works out better.
    Also using tagged for stationary targets.
     
    Last edited: Jan 24, 2014
  42. Phill123

    Phill123

    Joined:
    Jul 29, 2012
    Posts:
    11
    Hi,

    Thanks for making a great utility!
    However i have been stuck for multiple weeks, i just can't figure out what i'm doing wrong.

    I have an enemy prefab that gets cloned (several of them are onscreen at the same time)
    I have modified its health script so when it gets to zero health it uses Exploder.SendMessage("Explode");

    I have also attached the exploderobject script to this enemy, and var exploder is set as this enemy also

    This works perfectly for the first enemy i destroy, but after about 5 seconds i get the warning
    " The object of type 'fragment' has been destroyed but you are still trying to access it"

    Any subsequent enemy i kill doesn't explode at all and just repeats this message.

    I have tried making an empty gameobject as the exploder object and putting it inside the enemy, but this doesn't work either.

    Any ideas what i'm doing wrong?

    Very confused, and thanks for your reply.

    Phill


    Edit - I just tried lining up a whole pile of duplicates of the enemy in question, and i can explode them all one after another no problem at all. So that made me think it was the fact that Unity labels the clones as Enemy (Clone) causing the problem.

    I changed the instantiate script so that it would name them all 'Enemy' but that still won't work. Not that it would be a good solution anyway seeing as i have many different enemy types/names which all share that same health/death script.
     
    Last edited: Jan 27, 2014
  43. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    749
    I've had similar issues...
    Things to check try...
    when you call explode, there is a setting/checkbox on exploder, which decides wether your parent object is destroyed or not when it is exploded, probably set to true.
    So make sure you don't have any references to your 'enemy' gameObject or script that you are still accessing after you explode it, otherwise they will now be null... remove your object from any arrays or lists it may belong to before you explode it.
    also check where that error is being printed from, is it your code, or the exploder update code?
    why 5 seconds ? do you have any 5 second timers ?
     
  44. Phill123

    Phill123

    Joined:
    Jul 29, 2012
    Posts:
    11
    Thanks for that, i'll have another go.
    Also i found the 5 second reason - after the first enemy is destroyed, that error will pop up from the exploder script once the next enemy is instantiated.
    I'll have a better look into it all tonight and see if i can figure it out.
    I'm not using object pools at the moment for my enemy's, so it's possible this problem will go away when i fix that. I still have a feeling its the cloning process that's wrecking it.
     
  45. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    302
  46. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Great asset, one of the most useful I have bought, thank you very much!
    But I have a question, I would like to keep original object after explosion, because it will be processed by another asset and returned to pool.
    I looked at this code inside postprocess:
    Code (csharp):
    1.  
    2.                 foreach (var mesh in postList)
    3.                 ...
    4.  
    and added similar code, instead setting active to false I'm sending message to original component.
    It works fine, but I confused by content of postList list, it contains many copies of original mesh. Maybe this is a bug?
    What will be the correct way to identify set of original objects? Or should I create another list and keep it separately?
     
  47. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, thank you for using Exploder!

    postList is an internal structure, it contains copy of original GameObject 'original' which is deactivated before explosion, you can use it for keeping original objects. However there is another object called 'skinnedOriginal' which refers to original GameObject in case of skinned mesh.
    The reason behind this is because in case of skinned mesh Exploder has to bake the skinned mesh into a different GameObject and destroy that, so I need to keep another GameObject just for skinnedMesh.

    Anyway you can use this list for identifying original objects, it is a correct way, just be aware of skinned mesh objects, you can just check if the skinnedOriginal is not null.

    Regards.

    RG
     
  48. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Thank you for clarifying this, but it seems the list contains much more, e.g. fragments?
    This code executes many times for one original object, perhaps some bug in your code?
    Code (csharp):
    1.  
    2.     if (!crack)
    3.         {
    4.         if (mesh.original.activeSelf)
    5.         {
    6.             if (mesh.original != gameObject)
    7.                     {
    8.                         ExploderUtils.SetActiveRecursively(mesh.original, false);
    9.                              ...
    10.  
    postList contains several, seems to be identical copies of the same mesh.
    Could you please have a look? It may improve performance even more.

    P.S. Solved my original problem looking into HowToGetActiveFragments example, thank you again for that amazing asset!
     
    Last edited: Feb 8, 2014
  49. Steve-Tack

    Steve-Tack

    Joined:
    Mar 12, 2013
    Posts:
    1,240
    Hi, I'm trying to debug a problem with Exploder not exploding certain items. In my game, you can blow up space ships and asteroids, and both have been working fine for quite a while. But recently the space ships stopped blowing up, yet the asteroids still work fine.

    To try and diagnose my issue, I put tons of Debug.Log statements in ExploderQueue.cs and ExploderObject.cs. It looks like the space ships get as far as StartExplosionFromQueue (in ExploderObject.cs), but it never hits the InitPostprocess method.

    Any ideas on what could cause that behavior? It's a bit baffling, especially given how long it's been working perfectly.
     
  50. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    sorry for late reply, is it possible that all the fragments of the explosion are taken by asteroids? Did you try to explode just the ship and not the asteroids? Or maybe other thing, your ship model is not properly closed mesh, the mesh cutter might not work properly on open meshes (except 2d planes). Did you change your model recently?