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. reindeer-games

    reindeer-games

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

    What you describe is a bug, it shouldn't assign Explodable component to itself unless you set "ExplodeSelf" to true. You can easily fix it locally and I can include in the next update:

    1) open ExploderObject.cs script
    2) locate method Awake() (line 550 in latest version)
    3) comment out lines 570 to 577 where it adding Explodable component:

    Code (CSharp):
    1.  
    2.             // init queue
    3.             queue = new ExploderQueue(this);
    4.  
    5. //            if (DontUseTag)
    6. //            {
    7. //                gameObject.AddComponent<Explodable>();
    8. //            }
    9. //            else
    10. //            {
    11. //                gameObject.tag = "Exploder";
    12. //            }
    13.  
    14.             state = State.DryRun;
    15.  
    This will prevent adding of Explodable object to Exploder itself.

    Let me know if you have more problems.
     
    GrahamH likes this.
  2. GrahamH

    GrahamH

    Joined:
    May 5, 2014
    Posts:
    6
    Awesome, thanks!
     
  3. GrahamH

    GrahamH

    Joined:
    May 5, 2014
    Posts:
    6
    Is it possible there's a problem with the supplied Playmaker actions as well?
     
  4. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    No, the Playmaker should work well, I got message from user jayglossy that it is working correctly now after he changed the code according to documentation (in your post).
     
  5. GrahamH

    GrahamH

    Joined:
    May 5, 2014
    Posts:
    6
    Will take a look to see what I've done wrong. I've obviously got something set up incorrectly.
     
  6. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Let me know if you have more problems.
     
  7. Kamil_Reich

    Kamil_Reich

    Joined:
    Aug 14, 2014
    Posts:
    195
    Hi, I just have got one question: is there an option to explode body in parts, for example if I use shotgun on arm - only arm is destroyed? Something depends on which bone I shot? Or I have to modify it manually?
     
  8. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Interested in getting Exploder... Are all the options in the inspector for the scripts accessible by code? I'll need to set the options at runtime if possible. Thanks.
     
  9. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Oh hi, the madness sales link bring me here and I didn't notice its your asset until I see your portrait...:)
    Is this suitable for mobile? Is it works for any kinds of mesh? Thank you.
     
  10. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    please, is there any possible limitation of what kind of mesh can be destroyed?

    Can it it have one material on the outside and then another material on the inside when it gets fractured?

    Thanks very much for your help
     
  11. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Hi , I just purchased your great looking asset, I am trying to initiate the explode according to your docs.. but I am not seeing anything happen, my code is:

    var Exploder : GameObject = null;
    private var DestroyableObjects : GameObject[] = null;
    function Start () {
    Exploder.SendMessage("Explode");
    }

    Is this correct?

    In the console I see:
    SendMessage Explode has no receiver!
    UnityEngine.GameObject:SendMessage(String)
    explodetest:Start() (at Assets/explodetest.js:9)

    Do I need to move some scripts to a Unity Special Fodler?
     
    Last edited: Aug 12, 2015
  12. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    Exploder can explode only whole mesh, "local" explosions are not supported, what you can do is to separate meshes of your object explode each independently.
     
  13. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    thanks for interest in Exploder, yes, all options are available via public API and you can change them the same way as from the inspector. Examples and demos are included.

    Thanks.
     
  14. reindeer-games

    reindeer-games

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

    you can use exploder on mobiles, you can adjust settings of Exploder to lower settings (lower number of target fragments, frame budget for calculation, etc). There is even an option for cracking an object before the explosion so you can prepare your object when the level starts and execute the explosion immediately (works only for one object at time). Many developers use exploder on mobiles in production.

    Thanks.
     
  15. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    You can do this but only with one material. The material inside must be the same material as the original object, however you can specify portion of the texture "CrossSection UV", there is an explanation with picture in documentation. Thanks.
     
  16. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    About the mesh limitation question:

    Exploder works with any mesh and skinned mesh.
    Exploder does not work with Unity built-in sprites (because there is no mesh), but it can work with other 2d system (2D Toolkit) because they use the mesh.

    Exploder is more suitable for exploding smaller objects, like props, characters, vehicles etc. You can use it for buildings as well however the results are not always good as exploding smaller objects.

    Exploder can explode mesh with submeshes (with different materials) however the result will be a single mesh with single material.
     
  17. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, please copy the Exploder to "Plugins" folder (http://docs.unity3d.com/Manual/Plugins.html) and you can use the Exploder the same way as using C# (calling functions etc), so you don't have to use SendMessage, but call directly Exploder.Explode(...).
     
  18. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Thanks for the help. Could I ask for clarification, in the code "Exploder.Explode(...)" you sent, what is "..." , is the the name of the gameobject I should call "exploder" as per docs?
     
  19. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    It can be Explode() without parameters or Explode(OnExplode) with OnExplode callback. You can look in the file DemoClickExplode.cs and see how the Exploder is called, it's c# but if you copy Exploder to plugins directory, you will be able to use it in a very similar way.
     
  20. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Thanks for your help, "if you copy Exploder to plugins directory", do you mean the complete folder?
     
  21. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Yes, copy everything.
     
  22. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Ok so I moved to Plugins (and to Standard Assets also as a test), in my test .js file I changed:
    Exploder.SendMessage("Explode");
    to
    Exploder.Explode();

    The test script contains:
    var Exploder : GameObject = null;
    private var DestroyableObjects : GameObject[] = null;
    function Start () {
    DestroyableObjects = GameObject.FindGameObjectsWithTag("Exploder");
    Exploder.Explode();
    }

    Now I get error:
    BCE0019: 'Explode' is not a member of 'UnityEngine.GameObject'.

    Not sure why I am struggling so much with this, hopefully you won't mind to help more again.
    What am I doing wrong?
     
  23. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    I think you have to specify the type to be ExploderObject and not just a regular GameObject:

    Code (JavaScript):
    1. private var myExploder : Exploder.ExploderObject;
    2.  
    3. function Start() {
    4. myExploder.Explode();
    5. }
     
  24. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Hmm, that compiles ok but at runtime gives a NullReferenceException: Object reference not set to an instance of an object

    then If I change:
    private var myExploder : Exploder.ExploderObject;
    to
    var myExploder : Exploder.ExploderObject;

    then I get the error:
    NullReferenceException: Object reference not set to an instance of an object
    Exploder.ExploderObject.Explode (Exploder.OnExplosion callback) (at Assets/Plugins/Exploder/Exploder/ExploderObject.cs:382)
    Exploder.ExploderObject.Explode () (at Assets/Plugins/Exploder/Exploder/ExploderObject.cs:371)
     
  25. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    the script is correct, this works on my machine, I just assign Exploder object to this script in inspector and run the game:

    Code (JavaScript):
    1. var myExploder : Exploder.ExploderObject;
    2.  
    3. function Start () {
    4.     myExploder.Explode();
    5. }
    6.  
    Please try to move Exploder from "Plugins" folder to "Standard Assets" folder. There might be some different execution order rules for using JavaScript.
     
  26. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541

    Many thanks for your help.
    Ok, so I moved this into a test project , works ok there, I think what is different possibly is that I am instantiating objects, so the code in previous post would only exist/start once my object is instantiated..maybe that is why the callback fails?
    Also as I instantiate this I have to have the object as a prefab, I am creating a prefab from the Exploder object too. Is that a problem?

    NullReferenceException: Object reference not set to an instance of an object
    Exploder.ExploderObject.Explode (Exploder.OnExplosion callback) (at Assets/Standard Assets/Exploder/Exploder/ExploderObject.cs:382)
    Exploder.ExploderObject.Explode () (at Assets/Standard Assets/Exploder/Exploder/ExploderObject.cs:371)
    test.Start () (at Assets/test.s:6)

    How can I assign the Exploder object that is in my scene to
    var myExploder : Exploder.ExploderObject; if the script is on a prefab that I instantiate?
     
  27. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Exploder as a prefab is absolutely fine, the error means that the ExploderObject hasn't been initialized yet, it looks like script execution order problem. In your case don't have to assign the ExploderObject from inspector, but you can try to get the instance from singleton:

    Code (JavaScript):
    1.  
    2. var myExploder : Exploder.ExploderObject;
    3.  
    4. function Start()
    5. {
    6.     // get the exploder from the prefab
    7.     // make sure exploder prefab is in the scene
    8.     myExploder =  Exploder.Utils.ExploderSingleton.ExploderInstance;
    9.  
    10.     myExploder.Explode();
    11. }
    12.  
     
  28. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    Is there any news on combining this with pooling solutions?

    Why am I the only one who needs this feature -.-
     
  29. cj31387

    cj31387

    Joined:
    May 23, 2012
    Posts:
    143
    Is there any way to just call explode on a whole mesh without using the sphere exploder prefab? sometimes the prefab is not big enough for bigger meshes like a house. Is there any way to just quickly explode a mesh without the prefab? Like maybe from a raycast?
     
  30. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Yes! it works, Many thanks for your great help!
    One thing I did have to do is add

    #if UNITY_EDITOR
    using UnityEditor;
    #endif
    I some of your scripts as I moved all code to Standard Assets, in Editor mode everything worked, but once I did a full build I'd see errors eg:
    Assets/Standard Assets/Exploder/Exploder/Editor/EditorExploderUtils.cs(7,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?

    But these where fixed by adding
    #if UNITY_EDITOR
    #endif
    Where the errors came up.
     
  31. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, I want to attach a component to each fragment to control them, is that possible?
    What's "fragment prefabs" in the inspector(ExploderObject.Fragment options)? Docs said it doesn't support "fragment prefabs", that's confusing.
     
  32. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    sorry, the fragment prefabs were added in latest version and the docs hasn't been updated yet. Basically it's a very simple way how to get your custom code on prefabs:

    1. Create empty game object
    2. Add your custom script component
    3. Use this game object as a Fragment prefab (drag it in the inspector)

    When the object is exploded each fragment will have your custom script component.
     
    zhuchun likes this.
  33. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    the only way to explode without radius is by using option ExplodeSelf, but the exploder has to be on the object (meaning no exploder prefab, you have to add the ExploderObject component to that house).

    But I think the better way is to use the prefab and a simple workflow as described in the DemoClickExplode.cs:

    Code (CSharp):
    1. // move exploder object to the same position as the object
    2. Exploder.transform.position = ExploderUtils.GetCentroid(obj);
    3.  
    4. // adjust the radius of the exploder
    5. Exploder.Radius = 1.0f;
    6.  
    7. //
    8. adjust other options...
    9.  
    10. // call explode
    11. Exploder.Explode(OnExplosion);
    12.  
    You can use this technique even with Raycast (also described in the demo).

    Let me know if you have more problems.
     
  34. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    Sorry, to be honest this had lower priority until I forgot about it. I think one of the reason why most of the developers don't need it is because they use only one instance of Exploder (from prefab) and use it when they need it. Also I didn't have any pooling solution purchased and didn't have a strong reason to buy it. But recently I have acquired PoolManager 2.0 from Pathological games so I will look at the API.
     
  35. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    I have finally bought this on the Madness sale, and from the first tests I have done I think is really great and well done, and from what I have seen until now it seems to be very good, and seems to be easy to use, I have to begin to use it more to see if there could be any possible problem I may find, but until now I like it much

    I like much that the fragments from the exploded objects CAN BE EXPLODED AGAIN!!!!, this is really good and very good to have, so you can still keep exploding the generated fragments.

    Also like how the force is applied so the explosion goes in the same direction as the bullet goes, so gives some more realistic effects and is not just a simple collision effect and that makes a simple radial explosion, well done.

    and the only problem I may see is that as you say, you can only use one material and not able to use an internal material

    One thing I have seen in the FPS first demo, is that maybe the objects are too small, and you really can not see right the power and the very good fragmentation it makes, is all tiny bits, and when I have taken the barrel or vase and have scaled 3 times the size to have a huge one, you really can see how beautiful it is broken into pieces. I have to say that this has been one of the reasons I have not bought this before, because in the demo it was all tiny and you really could not see how the fragmentation was made.

    Also like much the well done group of random chairs, like it much to destroy them specially if you resize them 4 times bigger, and give a different material lighter, so you can see the shape of the fragments.


    The CrossSection UV that is on the point 8 of your documentation seems to be interesting and good way to have a different material texture, BUT is only useful IF you are using a UV texture for the material, but this would not work if what you want to use for an internal material is a shader effect, or another material that is not UV based. Also I think that you would need to make a new ATLAS for using this if the 3d model is not made by you, I mean one found on the asset store or anywhere else.

    Very good and great that Exploder can use any mesh and skinned mesh

    I will make some tests and see how it works with different sized objects, and how they are exploded

    The bad news is that if you have a mesh with submeshes and different materials, it will ONLY use one material, and so I want to ask, is this one material the one found on the main mesh? and so the material of the submesh is not taken?

    I really do not know what technical difficulties and why you are not able to have a second material for the internal parts, and maybe it can be very complex to make, as I do not know, because what I only know is the ones that use pre-fractured 3D model, that may have already prepared 2 materials, but what your tool is about is for dynamic destruction without having to use pre-fractured 3d models for each one.

    As said, as do not know what are the limitations and constraints of exploding meshes and how they work, I wonder if there could be any possible way to add in a future upgrade to be able to use a second material or shader as internal material.
     
    Last edited: Aug 22, 2015
  36. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    about the submeshes. The material of the submesh is not taken, always the main material (or the first material) is used for the result. Preserving submeshes with different materials would bring lots of complexity, currently the core of the Exploder works with a single mesh, it recursively cuts a mesh into 2 pieces, if there is a submesh it handles the submeshes as one mesh and use the same algorithm. Adding submesh support is not impossible but not easy either, I would say more than half of the Exploder core would have to be rewritten, because I would have to separate each sub-mesh, cuts them independently and combine them after. Also I would be worried about the performance since this is a real-time system and it's already optimized a lot.
     
    SpaceRay likes this.
  37. khos85

    khos85

    Joined:
    Jul 21, 2013
    Posts:
    541
    Not sure if you'd be interested how I'm masking use of your useful asset: see youtube vid:

    This game is going to steam also.. Watch the debris falling to the ground :)
     
  38. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    I have tested it now more, and I like it even more than before, and really is very worthy

    REPLACEMENT MATERIAL FOR EACH 3D OBJECT?


    I have seen that in the main Exploder Object script, at the end there is an optional material for fragments, if you select this and load a new material, it will then use THIS material instead of the original material found on the exploded model

    This is a very good option and idea, and it works very well, BUT I find a problem, if you replace this optional material it will then replace ALL the materials from ALL of the models on the scene, so when exploding ALL the fragments will have this same material, independently of whatever material they have

    So, thinking of this I wonder if it could be possible to put the optional replacement material inside the Exploder Option script in the same way as it is already done for the Cross Section UV, so this way each one of the 3D objects in the scene could have their own replacement material and do not share the same replacement material for all the 3D objects to be exploded found on the main script

    DO NOT WANT SUBMESH SUPPORT

    Sorry if I may have explained it wrongly and be mistaken, but I really do not want to have support for submeshes and do not want to preserve and keep the submeshes, as this is not the problem, and I agree to do it with just one only mesh (ignoring submeshes) and this is good to do it this way, and do not want that you rewrite you tool for this as is not the point

    SECOND INTERNAL MATERIAL OR SHADER?

    What I really would like is to be able to use a second Internal material OR Shader without having to use UV, so when the object is exploded, it would show a different material on the newly generated internal parts, I mean that on the outside would still have the original and main material of the 3D model, and in the inner parts of the fragments there could be a different material or shader

    BUT as I do not know how would be this be possible to make without having to rewrite what you have already done, as I do not know what technical problems you may have for this and how is built the material support

    Thanks
     
    Last edited: Aug 23, 2015
  39. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    I checked the code and the optional replacement material inside Exploder Option script is possible, it can be there as the Cross Section UV.

    However the second internal material or a shader is not. It is the "submesh" problem as I talked earlier, adding another internal material and/or shader means adding submesh support.

    I can add the custom material in next update, I think that is pretty reasonable feature.

    Regards.
     
    SpaceRay likes this.
  40. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    sorry there is no script support for groups, but I think this must be very simple to make, you can create script that change the tag Exploder to your objects depends on the group they are.

    1. Create group enum with items like player-1, team-red, movable, ...
    2. Assign each of your object this enum
    3. Now in your script where you call Explode() choose which group you want to explode, and check the object group and set Tag "Exploder" to the object if you want to explode it.
     
  41. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    Bought. Support for this. nice project
     
    reindeer-games likes this.
  42. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Thanks for the good news that it may be possible to have the replacement material inside the Exploder Option script, and is good enough

    Will be waiting for the update

    Do not worry if the second material is not possible because you would need to have submeshes

    Thanks
     
  43. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Hello,

    Please, I may be doing maybe something wrong and want to ask you

    How to have more fragments created when exploding ?

    I am using the first demo scene FPS, and want to rise the amount of fragments that are created when exploding the objects, so I went to the Hierarchy and Exploder gameobject, and then changed the fragment values in the inspector, from 10 to 300, but when I hit play to see the new fragmentation, the surprise is is exactly the same as before, and it breaks with the same amount of fragments, so maybe I should modify or change something else so the fragment count when exploding is rised.

    Can the size or scale of fragments created be changed or customized?
    How they are calculated?
    Does the size of the fragments depend on the amount of fragments created?

    Have diferent fragmentation for different objects on the same scene?


    i mean if It could be possible that if I have In the same scene, a small cube, a medium cube, a big cube and a huge, and I may want to have a different fragmentation amount for this 4 cubes, so the small cube, could have a low fragmentation, the medium will have a higher amount of fragments, and the huge cube will have much more fragments created

    Thanks very much for your help
     
    Last edited: Aug 29, 2015
  44. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    the FPS demo is configured from the script, there is a different Exploder settings for the rocket launcher/shotgun/grenade. So even you change the inspector some values are taken from the script at time of explosion.

    This is controlled by Target Fragments parameter, if you set this to 30, you will get 30 fragment pieces, doesn't matter what is the size of the original object. More Target Fragments means more smaller fragments etc.

    It is a recursive process of cutting the mesh in half by plane (with random rotation). First cut the original object in 2 pieces, than cut these 2 pieces into another 4 etc.

    Yes, from the script, all parameters are accessible from the script and Exploder can be configured for different usages in realtime (as done in FPS demo). So for example in the demo there is a shotgun that fragments object into 30 pieces and there is a grenade that fragments object into 100 pieces etc.
     
    SpaceRay likes this.
  45. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Thanks very much for you useful and detailed answer, well explained, now I understand it all and is helpful to know

    I have one question that I forgot to make and is very important for me

    How do you configure your own weapons to be make them compatible and use Exploder?

    What code need to be added to my weapon script?

    I have seen on the point 12 on the manual that you can add a part of the code to make your own weapons in UFPS, I do not use UFPS, I have my own weapons

    Oh, I see and understand why then it does not work as expected, because the values are taken from script and not from the exploder prefab itself, so it will work correctly, I mean the values, if I do NOT use the FPS demo, good to know

    Yes, this is what I thought and understood from the manual, what I was wrong and I was mistaken is because I tested it with the FPS demo that is followed, sorry.

    Thanks very much for all your help

    I send you my best wishes
     
  46. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Hello again,

    HOW TO USE YOUR OWN WEAPONS WITH EXPLODER?

    Thanks very much for your answer shown here below it did work right and well. (Open the quote to see it all)

    BREAK FRAGMENTS AGAIN WHEN FALLING BY COLLIDER?

    I had an idea I have seen in a fracturing video on youtube, as seen only shown at the 1:05 where the fragments hit other fragments or the ground and get more fractured.



    I mean that I want to ask how can be made that after the explosion is made, the fragments could be fractured again in more fragments IF they may hit other fragments or if they hit the ground?

    As far as I know, this could be done converting the fragments created into new explodable objects by collision instead of only by weapon.

    I know that you CAN now and is possible already to fragment again the created fragments if you shoot at them after the explosion, but when they fall to the ground,or hit any other object, these fragments are not fractured.

    Thanks for your help


    [
     
    Last edited: Sep 14, 2015
  47. vertexcolor

    vertexcolor

    Joined:
    Mar 11, 2013
    Posts:
    18
    does exploder work in unity 5 with 2D spirtes?
    I did see you video but I don't have the 2d-exploder prefab
     
  48. Vaupell

    Vaupell

    Joined:
    Dec 2, 2013
    Posts:
    302
    Hmmm, what am i doing wrong here..

    I get this error..
    NullReferenceException: Object reference not set to an instance of an object
    Exploder.ExploderObject.Explode (Exploder.OnExplosion callback) (at Assets/Exploder/Exploder/ExploderObject.cs:382)
    bulletMovement.OnTriggerEnter (UnityEngine.Collider hitObject) (at Assets/_scripts/Weapons/Ammo/bulletMovement.cs:56)

    I'm doing this

    Code (csharp):
    1.  
    2.     public GameObject exploderObj;
    3.     public ExploderObject Exploder; // This one has "exploder" scene object dragged on to it
    4.  
    5.     void Awake () {
    6.  
    7.         exploderObj = GameObject.FindGameObjectWithTag("ExploderControl");
    8.     }
    9. [/I]
    10.  

    Code (csharp):
    1.  
    2.     void OnTriggerEnter(Collider hitObject)
    3. {
    4.  
    5.         if(hitObject.tag == "Exploder") // hit explodeable objects
    6.         {
    7.             // insert explosion
    8.             lydKilde.clip = explosionSnd;
    9.             lydKilde.Play();
    10.             Debug.Log ("sound");
    11.  
    12.             // move exploder object to location
    13.             exploderObj.transform.position = hitObject.transform.position;
    14.             Debug.Log("move");
    15.  
    16.             // call exploder
    17.             Exploder.Explode();
    18.             Debug.Log ("explode");
    19.  
    20.             // remove object from game
    21.             Destroy(gameObject);
    22.         }
    23.   }
    24.  
     
  49. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi, I am not quite sure why you have 2 variables "Exploder" and "exploderObj", if you look at the DemoClickExplode.cs example there is only one public variable "Exploder" for controlling the exploder (moving to object location, setting up parameters and calling Explode()).

    The NullReferenceException error can be caused by wrong script execution order, for example Exploder is initialized after your objects and it doesn't work on first run. You can try to access Exploder via singleton before use and check if it is not null object:

    Code (csharp):
    1.  
    2. var ex = Exploder.Utils.ExploderSingleton.ExploderInstance;
    3.  
    4. if (ex != null)
    5. {
    6.    ex.gameObject.transform.position = ....;
    7.    ex.Explode();
    8. }
    9.  
    This will always get Exploder object after it is initialized.
     
  50. reindeer-games

    reindeer-games

    Joined:
    Mar 5, 2013
    Posts:
    547
    Hi,

    Exploder2D is a new project and it is still in development. Exploder does not work with sprites, it can work only with meshes.