Sprite Blaster


What the heck is Sprite Blaster?

Sprite Blaster is a plugin for Unity that allows you to do awesome 2D destruction effects like this:
SpriteBlasterAnimated1 SpriteBlasterAnimated2 SpriteBlasterAnimated3
What’s more, you can get it RIGHT HERE.

How does it work?

Sprite Blaster uses a special texture called a BlastMap to determine the pattern that it’s going to use to break apart your sprite. It simply passes this BlastMap along with your texture to a custom shader and then animates the result based on some curves. Please scroll down for more information on making your own BlastMap.

Why is this better than other solutions?

Two main reasons, performance and ease-of-use. Sprite Blaster doesn’t instantiate a single GameObject and uses very simple quads and shaders to do its stuff. It’s super simple to blast apart any sprite in your game, just a single line of code!

Does it work with sprites in an atlas?

Yup! Sprite Blaster perfectly handles sprites that have been sliced up via Unity’s Sprite Editor and works great with scaled and rotated sprites too.

How do I use Sprite Blaster?

You’re in luck, because here comes the…

…Quickstart Guide!

Step 0: Watch this video

Step 1: Install Sprite Blaster
This one is real easy, just search for Sprite Blaster inside Unity and follow the steps. Hopefully you’re already done this.

Step 2: Drag in the Sprite Blaster prefab
You should now see a “Sprite Blaster” directory in your project. Inside that directory is the SpriteBlaster prefab which looks like this:
or maybe this:
depending on how you roll.

Drag this prefab into your scene. The SpriteBlaster class is meant to be used as a singleton, and will set its static instance member on Awake. This prefab has already been configured with some reasonable defaults but you are free to change its settings to meet your needs.

Step 3: Call Thor.SpriteBlaster.Blast()
Now you’re set to start blasting sprites! From script, simply call:

For example, you’re probably using Unity’s SpriteRenderer component to render your sprites. You might attach the following script to your sprite object:

The SpriteBlaster class is part of the Thor namespace, so don’t forget prepend “Thor.”

Configuring Sprite Blaster

The SpriteBlaster component has a number of configuration options.

Blast Map
This is the texture that defines the shatter pattern that your sprites will follow when they break apart. Sprite Blaster comes with 3 such textures and you can change them up depending on your needs, or make your own if the 3 provided don’t suit you. More on this later!

Blast Material
Don’t change this unless you really know what you’re doing. This is the glue that hooks the shader to rest of the system.

X and Y Curves
These are the curves by which a given sprite piece will translate over its lifetime. X and Y curves are selected at random for each piece. The more variation in animation you want, the more curves you should define. The default curves make the pieces either go left or right, but always up and then down.

As an example, an X curve that looks like this:
would make your sprite piece linearly interpolate along the positive X-axis by 1 unit over the course of its life. The idea here with these curves is to be able to generate a random spread of pieces to emulate an explosion, akin to a particle emitter (though not as complex).

This defines the tint that’s applied to all sprite pieces over the course of their lifetime. The default simply makes them fade out near the end of their life.

Blast Duration
This defines the lifespan of each sprite piece, in seconds. Every piece for a given blast will have the same lifespan.

This is the rendering layer that the sprite pieces will be rendered on. If your game has custom layering needs, feel free to change this.

Making a BlastMap

A BlastMap is a texture that defines the shatter pattern for your sprite. They generally look like this:

Each color in the BlastMap defines another “piece”. This is super important, so I’m going to say it in a different color: Every piece of your BlastMap must be a different color. That’s the only rule! They can be of any size, but generally I like 256×256. The pieces can be touching, or they can be separated by transparency.

When it comes time to break your sprite up, it is overlaid at a random position on top of the BlastMap. For each color that it overlaps, a piece is created, resulting in N pieces for N colors. Your sprite is then redrawn N many times, with the BlastMap acting a mask, and a different color as the mask color for each piece. The process might be visualized like this:
Sprite1 >>>>     BlastMapOverlay >>>>     BlastMapResult >>>>     BlastMapFinalResult

You can see that the sprite overlapped 13 colors on its position in the BlastMap, which resulted in it being split in 13 pieces.

Some considerations

The smaller the pieces are in your BlastMap, the more pieces your sprite will be split into. This also means more processing power to render and animate those pieces. If this is a concern for your game, use a chunky BlastMap, like the provided BlastMap1. Keep in mind however, that if you’re attempting to split a sprite that is smaller than the largest piece of your BlastMap, you may get no breakage at all, so choose a map sufficiently granular for your average sprite.

If your sprite is larger than the BlastMap in either direction, the entire map will be used. This means that you will get as many pieces as there are colors in your map, which is lot! So just be careful.

BlastMaps must be read/write enabled within Unity and should have NO filtering applied (otherwise you’ll get a ton of extra unintended colors in your map). This is very important! Just make your texture settings look like the settings on the default BlastMaps and you should be good to go.


Have more questions about Sprite Blaster not answered here? Don’t hesitate to get in touch via the Contact Form. Blast on!