Search Unity

Exploder [RELEASED]

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

  1. karmacomp

    karmacomp

    Joined:
    May 2, 2014
    Posts:
    43
    I finally had a thought - read the manual. I never created a separate exploder object.

    Once I did this, it worked - kind of. I need two of anything for the object(s) to explode. Why?

    For example, one crate will disappear, two will explode.

    This is true for ANY object I create as an exploder. They will explode - but there must be two of them or the one object simply disappear.

    What am I doing wrong?

    Mike
     
    Last edited: Jun 25, 2014
  2. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    Hi there, Ive got this working, I must say its damn impressive, one thing I have noticed though after hours of very enjoyable testing, is that sometimes the explosion happens a second after the event. I fire a rocket, it hits and I hear the sound, then a second later everything explodes, Im assuming this is because the mesh is too complex, or is it something else?

    Also some stuff will only explode with the rocket launcher and not the normal gun, any ideas why? I love the grenade by the way, very cool to see your scene obliterated with a grenade :)

    Overall very impressed with this asset I have some great ideas on how to use it too, very exciting times.
     
  3. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    The best way is to have a separate game object with Exploder component. Just create an empty game object and assign ExploderObject component to it. It is better and easier to have only one Exploder object in the whole game, and then anytime just move that object to a different location and call Explode from the script, it will explode all objects in the radius. This is the best way to use it in FPS game.
     
    twobob likes this.
  4. reindeer-games

    reindeer-games

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

    Yes, if the explosion happens a second after the event, it can be caused by a complex mesh or by exploder settings, for example you specified too many fragments per explosion (in the demo there is a different settings for rocket and for gun).

    I am not sure why you don't see exploding some object with gun versus rocket launcher, but I guess it is also about different settings.

    Regards,
    RG
     
  5. karmacomp

    karmacomp

    Joined:
    May 2, 2014
    Posts:
    43
    But why do I need 2 objects? It seems I shoot/slam one and the ricochet of the pieces causes the second one to break - why is the 1st one invisible? BTW, I am using the cratebox and barrel from the Exploder folder - so no weird objects are being used.

    What did I miss?

    Mike
     
  6. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    The ricochet doesn't cause any break, it comes only from exploder. is it possible that you call method Explode() in a loop or on fast sequence? For example you call your method boom() many times in short time? It can be a problem. Try to call it only one time on the event.
     
  7. karmacomp

    karmacomp

    Joined:
    May 2, 2014
    Posts:
    43
    This is in the declared variables:

    Code (csharp):
    1. public ExploderObject Exploder;
    2. private GameObject[] DestroyableObjects;
    These are the main functions:

    Code (csharp):
    1. void boom()
    2.     {
    3.         // activate exploder              
    4.         ExploderUtils.SetActive(Exploder.gameObject, true);
    5.    
    6.         // move exploder object to the same position
    7.         Exploder.transform.position = ExploderUtils.GetCentroid(this.gameObject);
    8.  
    9.         Exploder.Explode(OnExplosion);
    10.     }
    11.  
    12.     void OnExplosion(float time, ExploderObject.ExplosionState state)
    13.     {
    14.         if (state == ExploderObject.ExplosionState.ExplosionFinished)
    15.         {
    16.             //Utils.Log("Exploded");
    17.         }
    18.     }
    Then I call:

    Code (csharp):
    1. boom();
    This is called at the DIE sequence of UFPS just after it removes bullet holes.

    What can I change/add to make this correct?

    Mike
     
  8. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    A new version 1.3.5 with particles and sound effects has been submitted to asset store:

    sfxOptions.png



    Should be downloadable in a few working days, enjoy!
     
  9. tequibo

    tequibo

    Joined:
    Jun 4, 2013
    Posts:
    19
    Nice!
    Would be cool if particles would attach to a center of a fragment, but I guess it that it would require a lot of work to implement?
    Anyway, thanks for that update!

    EDIT: or it would be a hit on performance?
     
    Last edited: Jul 4, 2014
  10. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Actually not, it is not a big problem to fix it, I add it to next update.

    Cheers.
     
    Rainking likes this.
  11. casperjeff

    casperjeff

    Joined:
    Apr 13, 2013
    Posts:
    333
    Possible bug in your new 'Uniform Distribution' logic (which I have been eagerly awaiting).
    I have some oddball cases with large radius explosions with complex object that are yielding Array Index Out of Range error. I can't give exact line in ExploderObject.cs as I've added some debugging and such...but it's on the line
    highlighted in bold below (buff[cutMesh.level] += 1;)

    if (UniformFragmentDistribution)
    {
    var buff = new int[64];
    foreach (var cutMesh in meshSet)
    {
    buff[cutMesh.level] += 1;
    }

    I did some debugging - the cutMesh.level that I am seeing sometimes FAR exceeds 64 - in the thousands sometimes.

    My scenes are fairly simple - with only a few 'Explodable' object within -
    Where I tend to see it is on a particular gameobject with 5 or 6 sub gameobjects (with meshes)...


    Any thoughts?
     
  12. Ash-Blue

    Ash-Blue

    Joined:
    Aug 18, 2013
    Posts:
    102
    For 2D am I able to make something burst into pixels instead of just regular fragments?
     
  13. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello,

    2D explosions are possible, you have to check "Use2D" in exploder settings and mark the object as 2d plane in exploder options component, more in docs (and use of 2d physics).

    Unfortunately it does not explode object to pixels, Exploder works only with meshes, so it always cut the object mesh into small pieces (fragments) as you can see in this video.
     
  14. asakawa12

    asakawa12

    Joined:
    Jul 23, 2014
    Posts:
    1
    Thank you for a great asset
    I am very grateful!

    Nice to meet you, too
    I am japanese
    Mobile Add-on for UFPS
    I want to explode the object with a gun.
    But not explode.
    Please tell me the FPS game other configuration methods.

    Heip me! !
     
  15. Rainking

    Rainking

    Joined:
    Jun 10, 2013
    Posts:
    41
    Hi,

    I like your asset! its a great tool. :) Do you have somewhere a performance guideline with some hints for good performance? I see big fps drops in the very moment my explosion starts. I played a lot with all values (frag pool, max fragments etc.) but on my PC and on my mobile device the framerate drops down below 10 fps.

    My Setup:
    3-15 Fragments
    200 Pool of Fragments
    30ms Framebudget
    No Colliders and no explodable Fragments
    Inherit parent physics
    Just 1 Exploder Object!

    Thanks in advance!
    Kind regards,
    Tino
     
    Last edited: Jul 28, 2014
  16. casperjeff

    casperjeff

    Joined:
    Apr 13, 2013
    Posts:
    333

    Couple of things to note - 30 ms will take nearly the entire framebudget (of 33ms or so) at 30 frames per second - leaving nothing for any other logic you might have in that same frame (hence a stutter )

    I have mine set lower - 15 or 20 depending...

    Another thing to note - I THINK I have determined (on my list to confirm) that each fragment gets a non-shared material (copy?) - causing not only a draw call jump (which can cause a stutter) but also might spike the rendering time when Unity has to compile/load those shaders (or at least one of them).
    Did you determine that this stutter happens mostly on the FIRST explosion and less so later on?
     
  17. Rainking

    Rainking

    Joined:
    Jun 10, 2013
    Posts:
    41
    Thanks for the fast response :) After some trial and error I found out that my explosions are much more fluid when I use the exploder tag instead of the explodable script. I changed it everywhere and now the stuttering at explosion start is nearly gone (framerate stays above 20 fps). I will play some more with your hints about framebudget!

    (fyi: I see the issue in every explosion not just the first)

    kind regards, Tino
     
  18. cj31387

    cj31387

    Joined:
    May 23, 2012
    Posts:
    143
    Really cool asset. I'm having a problem though, I followed the document on setting it up. My objects explode, but I want the fragments of that object to explode also, I set it up to do so and its not working. I see it working in the demo scene but I don't know why its not working in my scene.

    Also is the particle trails that follow fragments, out yet, that looks really cool, but I don't see it anywhere in the asset folder.
     
  19. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    to explode fragments you have to enable ExplodableFragments. Also make sure to setup everything like in the demo, one gameobject with ExploderObject and other objects with tag. Although there is a size limit for fragment object to be exploded based on its bounding box size, if there is a problem we can try to lower the settings in the code.

    The particles are ready to use. In the video I used standard particles from Unity, you can simply import them from Unity menu (standard assets/particles). Import them, pick your favourite and drag the particle prefab to Exploder inspector in SFX section.

    Regards.
     
  20. arcdragon1

    arcdragon1

    Joined:
    Oct 15, 2012
    Posts:
    116
    Hey, team.
    I buy after I have a trouble about Custom texture for inner side of exploded fragments.
    using skinned mesh character, I was setting uv (X Y Z W), but Cross Section is frequently an invisible.
    Could you help me out?
     
  21. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hello,

    I am sorry for the late reply, I must have missed notification from the forum.

    The cross section is invisible usually when the mesh has holes (it is not a closed mesh). If you are using option "Open mesh cutting", try to turn it off (leave it unchecked), it will be less tolerant for open meshes. Anyway it would help me if you can send me the some images or the mesh itself (you can use private message or my email).

    Regards.
     
  22. reindeer-games

    reindeer-games

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

    a new version of Exploder 1.3.7 is on the asset store.
    Changes:
    • Integration with UFPS camera (more info in docs)
    • Migration to Unity 4.5
    • Added namespace Exploder everywhere (thanks to 4.5)
    • Fixed crash with uniform distribution logic
    • Fixed crash with Physics2d and 2d toolkit
     
  23. RowdyMrB

    RowdyMrB

    Joined:
    Dec 8, 2012
    Posts:
    83
    Getting the following error when enabling Playmaker scripts. "Assets/Exploder/Playmaker/ExplodeAction.cs(47,40): error CS0246: The type or namespace name `ExploderObject' could not be found. Are you missing a using directive or an assembly reference?"
     
  24. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    My apologies, I forgot to test Playmaker actions with last update, please add this line to the playmaker script:

    using Exploder;

    the line can be added after the 7th line "using UnityEngine;".

    Thanks for feedback, I fix it immediately.
     
  25. RowdyMrB

    RowdyMrB

    Joined:
    Dec 8, 2012
    Posts:
    83
    No problem. Thanks for the quick response!
     
  26. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    1) You don't plan on implementing multi-object editing, do you? Setting up attributes for 70+ objects manually one at a time is kinda nuts.

    2) Also, why aren't (x) Explode Self and the Radius setting exclusive? Shouldn't one disable/enable the other, like other settings do?

    3) It seems that Exploder picks a random material from the exploded mesh. This is a problem for me since with my models not the whole model is covered by a UV-ed texture, large parts are covered by a flat, one-color texture. That means that often a flat black or blue texture is displayed, while others retain the UV'ed texture.
    Is there a way to force Exploder to a "prefered" material? Can you add that?

    4) Also, the docs are incomplete. The options under "SFX options" are explained nowhere.

    5) There is some weird behavior/bug where exploding fragments suddenly increase in scale during their lifetime if I use the "scale down" option. They suddenly pop larger.

    6) Is it possible to randomize the settings? I'd like to have something like: fragment count = 6 +/- 2. Lifetime = 3 +/- 1etc.
     
    Last edited: Aug 21, 2014
  27. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    I can implement multi-editing, it is not a big deal, however for this case of exploding multiple objects it is better (more memory friendly) to use only one Exploder instance as it is done for example in one of the demos (move exploder to the central position of the object and explode, etc.). But I guess that if you already have 70+ objects with Exploder component, it will be easier to use multi-editing.

    Actually they are not exclusive. Explode Self is an extra option if you want to explode also GameObject with Exploder component. Radius search for objects is applied in every case.

    Exploder picks the first (default) material, multiple materials (and submeshes) are not supported for performance reasons. Picking a preferred material can be done, I will add it to next update.

    Thanks for info, I will update the docs.

    Not sure why it is happening, I'll do some testing, thanks for feedback.

    Yes, I can do something about it.

    Thanks for feedback.
     
  28. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    Hi,

    thank you for our patience. I was a bit upset when I wrote this, because yesterday I really started integrating Exploder into my game.

    1) and 2)
    I can't really do the only-once-instance thing. My game simulates 2D gameplay in 3D, which means that the object can often overlap. That means that one Exploder instance with a radius search would also explode the attacking space ship (and potentially others) if only the destruction of the victim is needed.

    In my game there can be multiple space ships exploding, but I assume it will never start in the same frame. Is there a way to get around the entire radius search?
     
  29. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    No worries,

    the radius search can be disabled, it should be an easy fix, I will add it to next update.

    About the one instance thing, I see your point, it can be a problem in your game. I think I could add some parameter "Target object" that you want to explode and you can just mark it and not worry about other things like radius or positions. Anyway, I will think about it more and let you know.
     
  30. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    For my specific setup I don't need a "target object" parameter (if I understand you correctly here). For every space ship I have in my game there is a wreck variant that has a ExploderObject component. When a ship is destroyed, this wreck is spawned from my pool (using PoolManager 5) and Explode() is called. So I guess I really don't need the radius check.

    One might say that the radius might be useful for grenade like weapons that explode all object within a certain radius. But that is handled by my game logic, I don't Exploder here.

    But hey, if you can integrate 1) the "disable radius check" thing 2) the "prefered material" and 3) multi-editing then Exploder would be great for me. 4) would be the scaling-down pop-scale bug. Yet, 3) and 4) are lower priority (for me).

    EDIT:
    Say, can I set all of the ExploderObject parameters via script? That would take care of the randomization + the "editing 70 objects" problems.
     
    Last edited: Aug 22, 2014
  31. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Yes, you can set everything from the script. BTW, I already did the multi-editing and disabled radius, once I finished the material picker, I post it to store.
     
  32. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    check out the new update on asset store, version 1.3.9, I added:

    * multi-editing
    * disable radius scan (available when ExplodeSelf is checked)
    * optional material for fragments

    However I didn't fix the scale problem, I couldn't reproduce the bug, maybe you can tell me more information about your objects, is it happening for every object or always the same object? how is the object different from others, can be there some other script that tries to scale the object up, etc?
     
  33. tongchimlang

    tongchimlang

    Joined:
    Mar 12, 2014
    Posts:
    16
    How can i fix it? Please help me!
    Thank



    sorry for my bad english
     
  34. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    sorry for problems, I can't reproduce the problem on my machine. But it looks that the problem is in one of the testing scripts, which is not necessary for running the explosion. Please look at the inspector of the problematic object and remove the script component called "Test Vertex Colors".

    testVertexColors.png

    It should fix the problem.
     
  35. tongchimlang

    tongchimlang

    Joined:
    Mar 12, 2014
    Posts:
    16
    Thank for help..
     
  36. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    Hi,

    I returned to working with Exploder and yes, thank you for the new features, they work for me as expected. More one the scaling problem later ...

    In the meantime: How does Exploder work with PoolManager? As far as I can see, not at all. As mentioned in the past, I'd like to spawn wrecks for space ships from a pool, but there doesn't seem to be a way to "uncrack" models before putting them back onto the pool?

    If Exploder doesn't work with PoolManager (or other pooling solutions) at all, how does Exploder fare in real life use, given that pooling is mentioned as the number one performance boost in every talk or write-up on the subject?

     
  37. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I haven't tested Exploder with any pooling solutions available. There wasn't any reason to do so. Exploder itself contains a pooling system for fragments. There are N preallocated fragments (debris game objects) in the pool and when the explosion starts exploder pool manager activates necessary number of fragments (and just changes the mesh). If there are too many explosions, you can see that some of the fragments can disappear to be used somewhere else (in the latest explosion). So there are never more than N fragments in the game. N is "FragmentPoolSize" parameter with the default value 200, and can be adjusted in inspector or from the code.
     
  38. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    Hi,

    I did not mean the pooling "inside" Exploder, I mean the "outside", i.e. of ExploderObject GameObjects. If I can't pool ExploderObject objects (because you can't "unexplode" them), I have to use Instantiate and Destroy, which is discouraged for performance/smoothness gains.
     
  39. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Sorry for misunderstanding, I am sure we can improve this, the original object does not have to be necessary destroyed (deleted), by default the object is just deactivated. Anyway, I will look at the PoolManager to see what can be done.

    Thanks for feedback.
     
  40. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    Hi,

    thanks you for being open for suggestions. If you could make this work with PoolManager (or other pooling solutions) that would be awesome.
     
  41. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    Hi,

    I just tried setting up the ExploderObject from the outside via script, but ... some variables can be set via a public attribute. But many settings, the Fragment Options for example, can not be set from the outside? A lot of stuff is hidden in classes? There's not Setup() function that I can use to throw in a lot of variables?
     
  42. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, everything should be public, for example:

    Code (CSharp):
    1. public ExploderObject Exploder;
    2.  
    3. private void Start()
    4. {
    5.   Exploder.FragmentOptions.DisableColliders = true;
    6.   Exploder.FragmentOptions.UseGravity = false;
    7.   Exploder.SFXOptions.EmitersMax = 10;
    8. }
     
  43. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    Hi,

    right, but there are no

    Code (csharp):
    1. ExploderObject.fragmentOptions.explodableFragments
    2. ExploderObject.fragmentOptions.poolSize
    and a few others ...?

     
  44. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Well there are, however not all parameters match the inspector layout and names (the names in inspector are usually more user friendly), for example:

    Code (CSharp):
    1. Exploder.FragmentOptions.DisableColliders = true;
    2. Exploder.FragmentOptions.UseGravity = false;
    3. Exploder.SFXOptions.EmitersMax = 10;
    4.  
    5. Exploder.FragmentPoolSize = 30;
    6. Exploder.ExplodeFragments = true;
    7.  
    You can always look into ExploderObject class, or if you are using visual studio or mono develop, there is an auto-completion that can help. For all cases, I have generated doxygen documentation and put it on web:

    http://exploder.scienceontheweb.net/doxy/
    http://exploder.scienceontheweb.net/doxy/class_exploder_1_1_exploder_object.html

    Hope this helps.
     
    twobob likes this.
  45. DaVeF101

    DaVeF101

    Joined:
    Sep 7, 2014
    Posts:
    134
    I can't get any 2D sprites to explode at all.. 3D mesh object work no problem. I have added the ExploderOption to each 2D sprite gameobject and set tags to "Explode".. I've spent several hours on this and can't work it out.. I'm using a Sprite Renderer, could this be the problem?

    Any ideas?
     
  46. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    Yes, the Sprite Renderer is the problem. Exploder works only with meshes and there is no way to access mesh of built-in Unity sprites. It is a limitation of Unity.

    If you want to explode 2d sprites, you have to use one of the sprite libraries that use mesh. Exploder was successfully tested with 2D toolkit, which is the most commonly used 2d framework but it should work in general with any similar library.
     
  47. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    Hi,

    any news about making Exploder compatible with PoolManager?
     
  48. Infiniteno

    Infiniteno

    Joined:
    May 11, 2014
    Posts:
    11
    Is there a way for this to work on a rigidbody projectile using oncollisonenter?
     
  49. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    hii, i just played around with the demos, this seems a pretty interesting tool. I don't see myself using it as-is, but it could have a place in my plans. Primarily i find the cutting thing interesting. Did you have any unusual challenges or tricks to get that working in a responsive timeframe?

    I'm curious as to why the demos cull so agressively. I wanted to see how it performs under heavy load. Certainly culling debris is important, but it seems to completely discard all debris when you fracture a new object.
     
  50. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, thanks for your interest!

    the cutting algorithm makes calculations over several frames, there is a variable in settings (frame budget) that will set the maximum time in ms to spend in a single frame, so with reasonable settings you won't notice any spikes. The algorithm itself is using vertex hashing for finding contours instead of using heavy data structures like half-edge which is usual for similar applications. I tried to use only the simplest and memory friendly data structures and made lots of micro optimizations with unity profiler.

    Regards,
    RG
     
    Nanako likes this.