Mesh Explosion - Easily blast any mesh into pieces

Hi there.

I’d like to introduce my new script asset ‘Mesh Explosion’. It’s a super-easy-to-use script that takes any mesh and explodes it out into triangles. To use it you just add a single script onto your GameObject, and then at the appropriate time call its Explode() method (or send it an “Explode” message), and it will take the mesh, split it into its component triangles and animate them flying away.

It works on Unity Free and Pro, and on all platforms including mobile. Obviously on mobile it performs best with lower-poly models, but it works beautifully for exploding simple things like crates. It’s compatible with Unity 3.5 and 4, and in 4 or above it works with animated skinned meshes (Mecanim or legacy) as well as static ones.

The script is on the Asset Store now, and there’s a web player demo, and a YouTube demo/tutorial.

Here’s a screenshot of exploding the barrel model by SFC Paul Ray Smith Simulation Training Technology Center and licensed under the Creative Commons Attribution License.:

And here’s a screenshot of exploding the ‘Space Robot Kyle’ model (you can see this moving at about 5:20 in the YouTube video):

Any comments or questions are very welcome of course. Thanks!

1 Like

Awesome! Definitely on my next shopping list!
Bookmarked!

Glad to hear it. Thanks! :slight_smile:

Possible to have forces / gravity on the fragments?

Not yet, but that’s high on my to-do list.

There’s two way I can think of doing it: one would be to just add gravity to the visuals so that things fall nicely, and the other would be to make a new GameObject for each fragment with a collider and rigid body so that the fragments actually collide with the scene. Obviously that would be massively more expensive performance-wise, but might work well for low-poly things.

Did you have one or other of those in mind? Or something else?

Very nice!
Need to make something like random shell to add thickness for every broken fragment. Next update maybe? :slight_smile:

No solution in my mind, just would be nice to have (I would prefer the more performant solution as long as it looks kind of real).

Yeah, I think so. I guess it would either be a mesh collider or a slim box collider. I’ll do some tests and see what performs best. I think I’ll try it out now. :slight_smile:

Are you splitting them by their triangles? , meaning the object must be highly triangulated to get the effect in your robot video.

Yes that’s right, the objects are split into their triangles, so the effect looks best on objects with lots of them. Just to be clear, though, you don’t have to manually add a bunch of redundant vertices to your model to make the triangles separate from each other, because the script does that automatically.

Perhaps for objects with simpler geometries I could add an option to tesselate large triangles until they’re no larger than a given area so that the pieces are smaller. Would that be of interest?

Is there an option to only explode lower amount of polygons? Or is it just easier to swap in a lower res LOD model for explosion for this? Because I think exploding a full detail model seems kinda excessive - most explosion you only get few piece of shrapnels and chunks of original object. So what I am asking is - is it possible to break object into chunks and bits of that are shrapnels?

Let’s take the barrel for example - if the explosion is at the middle - it will rip the barrel apart and the top chunk most likely to fly off while bottom chunk explode into several pieces and the middle bit are little shrapnels.

I’ve added an option to apply gravity to the exploding fragments. This is just the simple visual effect that I described as the first option in my earlier post, but I think it looks quite nice. Here’s a very quick video demo of it in action:

It’s been submitted to the Asset Store as version 1.1 and will hopefully be up soon. I’m going to explore the more complex option of actually adding physical collisions to the fragments, though, and I’ll post again when I have some news on that. Thanks for the suggestion Cascho01!

Very cool script. Might have to invest in this. I have been thinking about doing an exploding text effect and this might be the perfect thing. Have you got any test data for mobile in terms of how many polys there can be before there is a performance hit?

Right now it explodes every polygon, so yes you’d need to swap in a lower LOD model if you want fewer fragments. I haven’t played with the Unity LOD system yet, but perhaps the script could help with that by having a LOD bias option to select a lower LOD version of your model automatically.

On the asset store page one of the screenshots shows an iPad 1 exploding a 184-vertex mesh and that was at a solid 60 fps. If you’re targeting 30 fps or faster hardware then you can go higher of course. I just did a quick test and I’m getting a solid 30 fps on iPad 1 with a 482 vertex mesh. I have an iPhone 3GS, 4S, and iPad 1, 2, and 3, so if you let me know what your hardware/frame rate target is I’d be happy to get you numbers for that.

Yes, that would be useful. I assume you cache which parts of the triangle wil lbe splitted, so you can preprocess that in editor, not at runtime.

The other concern about splitting is the texturing on edges which are not split properly

Also, lastly, I would see you have to switch shade to doubleside, cos like the robot, the interior face is not drawn. Then how do u handle transparencies.

Wow, I had to double check the price, I could of swore I missed a zero .

Next thing I buy forsure …

Looks great !

Yes it is cached, so if you are exploding lots of GameObjects with the same mesh you only pay for the pre-processing once. It’s actually done at runtime though, on Start(), rather than in the editor. The rationale for that is that the pre-processing is actually pretty quick and I think it’s better to waste a millisecond or whatever it is on level load rather than wasting some storage. I haven’t tried out tessellation yet, but I suspect that would still be fast enough that it would make sense to do it at runtime.

I’m not sure I understand what you mean here. Could you go into a bit more detail?

Actually the script adds extra geometry to the explosion mesh for the the back sides of each triangle so that it can use the original shaders. If the original shader doesn’t handle transparency, though, it does swap it out for a transparent version (so if you’re using “Bumped Specular” for example, it looks up “Transparent/Bumped Specular”) when the triangles start to fade.

Yes, this is what I mean. When you add extra geometry, how does the UV handled properly. My experience for precut mesh, the artist still needs to touch up the UV in the cut portion.