How to make a Game Object disappear in an Explosion

I am using the Detonator set of parametric explosions and I have been having a lot of success with it (great download). I am using the semoflange as a bomb and a stack of cubes as a wall. I want the bomb to blow up and make the cube it hits and the semoflange disappear. I can get the explosion to work, and I can get the cube to disappear. However, I can’t make the bomb disappear (if I do, since the Explosion scripts are attached to the semoflange, the Explosion disappears also).

I have tried to instantiate an Explosion at the Location of the collision, but that didn’t work, because it would not detonate. I also tried to make the semoflange a child of the Explosion, but that didn’t work either.

Thanks for the help, Rex

2 Answers

2

You could deactivate the cube’s mesh renderer (making it invisible) and give a delay value to Destroy so that it doesn’t destroy your game object until the explosion effect is done. For example:

renderer.enabled = false;
Destroy(gameObject, 5f);

I actually ended up creating a GameObject called Explosion, which I then instantiated when the objects collide. I was then able to Destroy both colliding objects at the same time, and leave the Explosion GameObject. I’m sure your Suggestion will work also, but I already changed a lot of code.

Thanks very much for the help!