Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Exploder [RELEASED]

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

  1. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    302
    the 2 instances was just a debugging test, because i can't use exploder as a gameobject,
    i have inside a empty gameobject, else i wont be able to use "FindGameObjectWithTag" because the script does not "know" the exploder until it's run. So it needs to locate the exploder in the scene first.

    The dragged into thing, is also only a debug temp thing, because it didnt work initially.

    I am
    Code (csharp):
    1. using Exploder
    However, i donot have access to the ****.Utils.ExploderSingleton.ExploderInstance; instruction.



    Do you have an suggestion on how i could potentially find the ExploderObject and assign it to my variable?

    guesswork code below, how i normally find GameObjects.
    Code (csharp):
    1.  
    2. public ExploderObject ExploderObj;
    3.  
    4.  
    5. void Awake() {
    6.  
    7. ExploderObj = GameObject.FindGameOjectWithTag("ExploderController");
    8.  
    9. }
    10.  
    But ofcourse this wont work, because it's the wrong type.
     
    Last edited: Sep 21, 2015
  2. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    It looks like the name is clashing with Exploder namespace, name you exploder object differently if you use keyword
    Code (CSharp):
    1. using Exploder;
    Name it for example:

    Code (CSharp):
    1. ExploderObject exploderObj;
    If you can't access the singleton, it's probably similar problem, you can use keyword global to override that:

    Code (CSharp):
    1. var ex = global.Exploder.Utils.ExploderSingleton.ExploderInstance;
     
  3. vertexcolor

    vertexcolor

    Joined:
    Mar 11, 2013
    Posts:
    18
    will it be in the exploder asset or will it be a new asset ?(and if it is a new asset how much is it gonna be?)
     
  4. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, it will be a new asset, the core algorithm is rewritten and optimized to 2D sprites, I haven't decided about the price, but I think around 20 dollars.
     
  5. vertexcolor

    vertexcolor

    Joined:
    Mar 11, 2013
    Posts:
    18
    Okay, maybe I'll buy it.
    Succes!
     
  6. Gozdek

    Gozdek

    Joined:
    Jun 21, 2015
    Posts:
    356
    Excellent work!
     
  7. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    I can't get the pre-crack to work.

    In the demo I swap in the #DEFINE but clicking on something does not appear to ever hit the "Cracked" stage.
    upload_2015-10-1_18-19-42.png

    Clicking the wood does not result in explosion, simply ever cycling post processing time...
    upload_2015-10-1_18-19-16.png

    I also tried it in my own project, however the callback never returns from the singleton Crack method...

    Exploder.Crack(OnCracked); <-- Never happens
    so... ExplodeAfterCrack(); doesn't either

    Any clues?

    I did read the docs. a couple of times.
     
    Gozdek likes this.
  8. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    I just tested the demo and it works perfectly, I uncomment the line like you did, I click left mouse button on object, I get callback OnCracked, then I click right button on the same object and get the explosion. How about the Explode(...) does it work when you don't use the crack?
     
  9. allinlabs

    allinlabs

    Joined:
    Dec 31, 2012
    Posts:
    15
    Hi all,

    Did anybody managed to modify the default scripts to explode at a given point in space? Or even a given plane?

    I'd like to destroy only a part of the model, and not the whole thing. Not sure if it's possible though...

    Thanks
     
  10. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, unfortunately this is not possible. Exploder can explode only a whole mesh.
     
  11. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Hi. we are having fun with exploder but were wondering if you had any advice on keeping down garbage?



    Much obliged
     

    Attached Files:

  12. intrikit

    intrikit

    Joined:
    May 25, 2013
    Posts:
    130
    Has anybody tried this with bodies exploding? I need something that blows human enemies to pieces.
     
  13. DannyWoo

    DannyWoo

    Joined:
    Oct 25, 2012
    Posts:
    24
    How can i using Custom fragment prefab (option for using custom object for fragment pieces)?

    i made a Cube to prefab and set it to fragment prefab slot.

    and exploded it

    but fragments wasn't my prefab.

    am i misunderstanding?
     
  14. intrikit

    intrikit

    Joined:
    May 25, 2013
    Posts:
    130
    Things are working great! However, I am getting some fragments that do not appear to be part of my original mesh. They look like fragments of untextured cubes.

    Untitled-1.jpg
     
  15. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    custom prefab is useful for adding a custom script on the generated fragment. The mesh and rigid body will be overwritten by the new fragment piece during explosion, that's why you don't see any cube. I don't see a reason why you want to add a custom mesh and then use Exploder fragment for it, it's the purpose of Exploder to generate the fragment meshes.
     
  16. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    To keep down the garbage the best is to use DeactivationOption in Exploder inspector, you can set it on timeout and all garbage will disappear after. Optionally you can do it from the script, there is an example in Examples directory with file "HowToGetActiveFragments.cs", it shows how to get fragments in the scene from the script.
     
  17. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    We tried all that, we still ended up with 1+Mb garbage chunks w/e we attempted a split.
    anyway, appreciate the feedback.
     
  18. reindeer-games

    reindeer-games

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

    I would like to announce a new store product Exploder 2D: Realtime sprite explosion system.

    logo.png

    Exploder 2D is a realtime sprite explosion system for Unity. It can explode any Unity sprite object in a matter of milliseconds!

    Exploder 2D is a younger brother of original Exploder package. The core algorithm was greatly simplified and optimized for 2D processing. It results in excellent performance and smaller memory footprint on mobile devices.

    Web Demos:

    Platformer Demo
    Click and Explode Demo
    Android APK

    Documentation






    Link to store:
    https://www.assetstore.unity3d.com/en/#!/content/44531

     
  19. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    a new version of Exploder was just uploaded to Asset Store, there is a slight change in public API, I split the main method Explode into:
    • ExplodeObject(...)
      • for exploding single object (the radius is ignored)
    • ExplodeRadius(...)
      • for exploding objects in radius (current functionality)
    This should help you to use Exploder better in cases you want an isolated explosion of a single object.
     
  20. alexthomasren

    alexthomasren

    Joined:
    Dec 24, 2013
    Posts:
    11
    Hi Reindeer Games,

    Just bought this asset, and trying it out in playmaker. I've done the uncomment thing in the preprocessor, and now Unity is giving me this error:

    Do you have any tips on how to fix this?

    Best,
    Alex
     
  21. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    please update to version 1.3.3. I forgot to test Playmaker with the latest update and made a bug. The version 1.3.3 should be live on Asset Store in 20 minutes.

    Let me know if you have more problems.
     
  22. alexthomasren

    alexthomasren

    Joined:
    Dec 24, 2013
    Posts:
    11
    Thanks Reindeer Games! No problems.
     
  23. mikewirthart

    mikewirthart

    Joined:
    Sep 2, 2015
    Posts:
    8
    Would love to integrate this with the Game Camera asset, but am getting stuck integrating the demo script from Exploder. Any one try this yet?
     
  24. mikewirthart

    mikewirthart

    Joined:
    Sep 2, 2015
    Posts:
    8
    Any new documentation? Just tried to integrate into Game Camera without success.
     
  25. mikewirthart

    mikewirthart

    Joined:
    Sep 2, 2015
    Posts:
    8
    Would love to know how you integrated this into a third person game?
     
  26. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    What kind of integration do you need? Cannot see any connection between Exploder and camera.
     
  27. mikewirthart

    mikewirthart

    Joined:
    Sep 2, 2015
    Posts:
    8
    We're trying to make the worms and zombies in Game Camera explode when shot. We've imported the exploder and game camera packages into a scene and followed the getting started steps and are stuck. We need help knowing where to calling the explode() command in our project? It also appears that explode() doesn't exist in the latest version. Any help is appreciated.
     
  28. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    yes, the Explode() was replaced with two functions

    ExplodeRadius()
    ExplodeObject(),

    Sorry I'll update the documentation. If you are using GameCamera you can look at the TargetManager and methods Shoot and ShootAt, in that place the hit target is calculated, so you can place your exploder code there, you can use the new function exploder.ExplodeObject(hitObject)
     
  29. mikewirthart

    mikewirthart

    Joined:
    Sep 2, 2015
    Posts:
    8
    Thank you! Found the targetmanager and the shootat method. I'm not sure how to reference the exploder script from inside the target manager script. What do I need to call in order to use the explode method in the shootat method?

    Thank you.
     
  30. mikewirthart

    mikewirthart

    Joined:
    Sep 2, 2015
    Posts:
    8
    Should I be trying to combine the scripts or can I just call explode() from within the target manager?

    Code (CSharp):
    1. // Version 1.1.18
    2. // ©2013 Reindeer Games
    3. // All rights reserved
    4. // Redistribution of source code without permission not allowed
    5.  
    6. using System.Collections.Generic;
    7. using UnityEngine;
    8. using System.Collections;
    9. using UnityInput = UnityEngine.Input;
    10. //NEW
    11. using System.Linq;
    12. using Exploder;
    13.  
    14. namespace RG_GameCamera.CharacterController
    15. {
    16.     public enum TargetType
    17.     {
    18.         Enemy,
    19.         Default,
    20.         UseObject,
    21.         None,
    22.     }
    23.    
    24.    
    25.    
    26.     /// <summary>
    27.     /// target manager is used for determining game object in aim direction from camera
    28.     /// in the demo it is used for detection of enemy entities
    29.     /// </summary>
    30.     public class TargetManager : MonoBehaviour
    31.     {
    32.         public static TargetManager Instance
    33.         {
    34.             get { return instance; }
    35.         }
    36.        
    37.         private static TargetManager instance;
    38.        
    39.         public GameObject TargetObject;
    40.         public TargetType TargetType;
    41.         public Vector3 TargetPosition;
    42.         public bool HideCrosshair;
    43.         private Vector3 hitPos;
    44.         //NEW
    45.         private GameObject[] DestroyableObjects;
    46.         private ExploderObject Exploder;
    47.         //
    48.        
    49.         public GUITexture CrosshairGun = null;
    50.         public GUITexture CrosshairHand = null;
    51.         public Camera Camera = null;
    52.        
    53.         private void Awake()
    54.         {
    55.             instance = this;
    56.         }
    57.        
    58.         private void Start()
    59.         {
    60.             Utils.Debug.SetActive(CrosshairGun.gameObject, true);
    61.             Utils.Debug.SetActive(CrosshairHand.gameObject, true);
    62.            
    63.             if (!Camera)
    64.             {
    65.                 Camera = CameraManager.Instance.UnityCamera;
    66.             }
    67.            
    68.            
    69.            
    70.            
    71.         }
    72.        
    73.         //NEW
    74.         private bool IsExplodable(GameObject obj)
    75.         {
    76.             if (Exploder.DontUseTag)
    77.             {
    78.                 return obj.GetComponent<Explodable>() != null;
    79.             }
    80.             else
    81.             {
    82.                 return obj.CompareTag(ExploderObject.Tag);
    83.             }
    84.         }
    85.        
    86.         private void Update()
    87.         {
    88.             // run raycast against objects in the scene
    89.             var mouseRay = Camera.ViewportPointToRay(new Vector3(0.5f, 0.5f));
    90.            
    91.             TargetObject = null;
    92.             TargetType = TargetType.None;
    93.             TargetPosition = Vector3.zero;
    94.            
    95.             var hits =
    96.                 new List<RaycastHit>(Physics.RaycastAll(mouseRay, Mathf.Infinity));
    97.             GameObject hitObject = null;
    98.            
    99.             if (hits.Count > 0)
    100.             {
    101.                 hits.Sort(delegate(RaycastHit a, RaycastHit b)
    102.                           {
    103.                     return (Camera.transform.position - a.point).sqrMagnitude.CompareTo(
    104.                         (Camera.transform.position - b.point).sqrMagnitude);
    105.                 });
    106.                
    107.                 hitObject = hits[0].collider.gameObject;
    108.                 TargetPosition = hits[0].point;
    109.                 hitPos = hits[0].point;
    110.             }
    111.            
    112.             if (hitObject != null)
    113.             {
    114.                 TargetObject = hitObject;
    115.                 TargetType = TargetType.Default;
    116.                
    117.                 var hitEntity = TargetObject.GetComponent<HitEntity>();
    118.                 if (hitEntity && !hitEntity.IsDead && hitEntity.Enemy)
    119.                 {
    120.                     TargetType = TargetType.Enemy;
    121.                 }
    122.             }
    123.            
    124.             switch (TargetType)
    125.             {
    126.             case TargetType.Enemy:
    127.                 CrosshairHand.enabled = false;
    128.                 CrosshairGun.enabled = true;
    129.                 var color = Color.red;
    130.                 CrosshairGun.color = color;
    131.                 break;
    132.                
    133.             case TargetType.UseObject:
    134.                 CrosshairHand.enabled = true;
    135.                 CrosshairGun.enabled = false;
    136.                 break;
    137.                
    138.             case TargetType.Default:
    139.             case TargetType.None:
    140.                 CrosshairHand.enabled = false;
    141.                 CrosshairGun.enabled = true;
    142.                 var clr = Color.white;
    143.                 clr.a = CrosshairGun.color.a;
    144.                 CrosshairGun.color = clr;
    145.                 break;
    146.             }
    147.            
    148.             if (HideCrosshair)
    149.             {
    150.                 CrosshairGun.enabled = false;
    151.                 CrosshairHand.enabled = false;
    152.             }
    153.            
    154.             // activate use object
    155.             if (UnityInput.GetKeyDown(KeyCode.E))
    156.             {
    157.                 if (TargetType == TargetType.UseObject)
    158.                 {
    159.                     //                    var useObject = TargetObject.GetComponent<UseObject>();
    160.                     //
    161.                     //                    if (useObject)
    162.                     //                    {
    163.                     //                        useObject.Use();
    164.                     //                    }
    165.                 }
    166.             }
    167.         }
    168.        
    169.         public void Shoot(HitEntity owner, float damage)
    170.         {
    171.             if (TargetType == TargetType.Enemy)
    172.             {
    173.                 var hitEntity = TargetObject.GetComponent<HitEntity>();
    174.                
    175.                 if (hitEntity)
    176.                 {
    177.                     hitEntity.OnHit(owner, damage, hitPos);
    178.                 }
    179.             }
    180.         }
    181.        
    182.         public void ShootAt(Vector3 aimVector, HitEntity owner, float damage)
    183.         {
    184.             // run raycast against objects in the scene
    185.             var ray = new Ray(owner.transform.position + Vector3.up, aimVector);
    186.            
    187.             var hits = new List<RaycastHit>(Physics.RaycastAll(ray, Mathf.Infinity));
    188.             GameObject hitObject = null;
    189.            
    190.             //exploder.ExplodeObject(hitObject);
    191.            
    192.             if (hits.Count > 0)
    193.             {
    194.                 hits.Sort(delegate(RaycastHit a, RaycastHit b)
    195.                           {
    196.                     return (Camera.transform.position - a.point).sqrMagnitude.CompareTo(
    197.                         (Camera.transform.position - b.point).sqrMagnitude);
    198.                 });
    199.                
    200.                 hitObject = hits[0].collider.gameObject;
    201.                 hitPos = hits[0].point;
    202.             }
    203.            
    204.             if (hitObject != null)
    205.             {
    206.                 var hitEntity = hitObject.GetComponent<HitEntity>();
    207.                 if (hitEntity && !hitEntity.IsDead && hitEntity.Enemy)
    208.                 {
    209.                     hitEntity.OnHit(owner, damage, hitPos);
    210.                 }
    211.             }
    212.         }
    213.     }
    214. }
    215.  
     
  31. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    just call ExplodeObject withing the manager, like this would be better:

    Code (CSharp):
    1.  
    2.         public void ShootAt(Vector3 aimVector, HitEntity owner, float damage)
    3.         {
    4.             // run raycast against objects in the scene
    5.             var ray = new Ray(owner.transform.position + Vector3.up, aimVector);
    6.          
    7.             var hits = new List<RaycastHit>(Physics.RaycastAll(ray, Mathf.Infinity));
    8.             GameObject hitObject = null;
    9.  
    10.             if (hits.Count > 0)
    11.             {
    12.                 hits.Sort(delegate(RaycastHit a, RaycastHit b)
    13.                           {
    14.                     return (Camera.transform.position - a.point).sqrMagnitude.CompareTo(
    15.                         (Camera.transform.position - b.point).sqrMagnitude);
    16.                 });
    17.              
    18.                 hitObject = hits[0].collider.gameObject;
    19.                 hitPos = hits[0].point;
    20.             }
    21.          
    22.             if (hitObject != null)
    23.             {
    24.                 // get & run exploder
    25.                 var exploder = Utils.ExploderSingleton.ExploderInstance;
    26.                 exploder.ExplodeObject(hitObject);
    27.  
    28.                 var hitEntity = hitObject.GetComponent<HitEntity>();
    29.                 if (hitEntity && !hitEntity.IsDead && hitEntity.Enemy)
    30.                 {
    31.                     hitEntity.OnHit(owner, damage, hitPos);
    32.                 }
    33.             }
    34.         }
    35.     }
    36. }
    37.  
     
  32. mikewirthart

    mikewirthart

    Joined:
    Sep 2, 2015
    Posts:
    8
    Thank you! Does Exploder need to be in a special place? I'm getting an error like this:

    "Assets/GameCamera/Scripts/CharacterController/TargetManager.cs(205,54): error CS0234: The type or namespace name `ExploderSingleton' does not exist in the namespace `RG_GameCamera.Utils'. Are you missing an assembly reference?"
     
  33. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    you are just missing Exploder namespace, you can use keyword using or a full reference:

    Code (CSharp):
    1. var exploder = Exploder.Utils.ExploderSingleton.ExploderInstance;
     
  34. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    Hey i got Exploder some time ago, and the moment to use it has arrived.
    Im using Unity 469, which Exploder version supports it? 1.3.3 doesnt import in U4.

    Thank you in advance
     
  35. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I think 1.3.13a was the last version using Unity 4, I stopped to support Unity 4 more than a half year ago. Is it a problem for you to upgrade to Unity 5? I think the code can be converted easily to Unity 4, but not the demo scenes since they use a different format.
     
  36. mikewirthart

    mikewirthart

    Joined:
    Sep 2, 2015
    Posts:
    8
    Got it to connect to the explodersingleton script! However, it's not exploding when I shoot the items with the exploder tag.
     
  37. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    Thanks man! I have U4 PRO (but not 5pro) and am working on a couple of projects that i wont port to 5. I don't need the latest version, just one that i can work with. Do you still have 1313a? Can i PM you my invoice # and get it?

    Thanks
     
    Last edited: Dec 2, 2015
  38. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    yes, I can PM you the older version, I should find it in my GIT repo, or if you don't mind I can give you latest source code without demos working in Unity 4, because the source code should be very easy to convert back to 4.x, but not the scene files.
     
  39. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    Thank you very much!!
     
  40. K0m1x

    K0m1x

    Joined:
    Aug 19, 2013
    Posts:
    30
    when having complex shapes it doesn't seem to do the inner polygons very well. is there any way to improve that?
    what I mean is that there are bi gaping holes in them mostly, which make it much less awesome
     
    Last edited: Dec 5, 2015
  41. PhoenixRising1

    PhoenixRising1

    Joined:
    Sep 12, 2015
    Posts:
    488
    I assume this will work well for destroying crates and vases with a melee weapon, correct? :)
    Don't want the pieces flying too unrealisticly.
     
  42. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    in case of complex meshes, you can try to turn on the option "OpenMeshCutting", however this will ignore the triangulation for most of the parts but it will cut the object into more pieces (the cutting will be more stable and faster). Also in case of complex meshes try to use meshes without holes in the geometry, because Exploder can't triangulate that part.
     
  43. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Yes, exactly, this will work perfectly for destroying small props in your game.
     
  44. montyfi

    montyfi

    Joined:
    Aug 3, 2012
    Posts:
    548
    Look at this (skip to 20s and also at 31s) all crashes done with Exploder
     
  45. PhoenixRising1

    PhoenixRising1

    Joined:
    Sep 12, 2015
    Posts:
    488
    Awesome.
     
  46. PhoenixRising1

    PhoenixRising1

    Joined:
    Sep 12, 2015
    Posts:
    488
    Thanks for the clip :).
     
  47. Amnoon

    Amnoon

    Joined:
    Jul 20, 2013
    Posts:
    31
    Hello! First of all awesome package!
    I have a question. There is some way to precalculate the fragmented mesh in the editor and then just use it instead of calculate the fragments in real time? I am experimenting some performance issues if I explode a lot of meshes at the same time and I wonder if some kind of precalculation it's possible to achieve.

    The perfect thing it's beeing able to crack all the objects in the scene that I want to explode and store the result to use it on play. I don't know if this is possible.

    Thanks for the help!
     
    Last edited: Dec 17, 2015
  48. Alex-3D

    Alex-3D

    Joined:
    May 21, 2013
    Posts:
    79
    Hi,
    There exists some rules for public libraries development. The most important of them is that you should never change external signature of classes. You can add any count of new members, you can add any overloaded variants of them, you can mark any of existing member as deprecated, but you should NEVER change them!
     
  49. mccann

    mccann

    Joined:
    Sep 24, 2013
    Posts:
    30
    Bought this asset awhile ago, but just now finally getting to use it. I took a simple rectangle shape 3d box and exploded it, but ended up with lots of different shapes including 1/2 circles. Did I do something wrong? I don't think I should have seen any 1/2 circles from exploding a box shape.
     
  50. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    Exploder is runtime only, there is no way of pre-calculation inside the editor. The only closest thing is the Crack feature, but it has limitations. You can only crack and explode only one object at the time.
     
    Last edited: Jan 4, 2016