Home

2D butterflies with Unity's particle system

Year:
2021
Type:
Tutorial
Tech:
Unity Particle System, Aseprite

Unity's particle system is a godsend! You can use it to create all kinds of effects. In this tutorial, I'll show you how to make butterflies using texture sheet animation.

You can see this effect in my game Super Eyebrow Princess.

Let's start

To start off, you'll need the butterfly sprites. I made mine in Aseprite.

2D Butterflies using the unity particle system tutorial image - bsesp

Export it as a spritesheet.

2D Butterflies using the unity particle system tutorial image - sp

Or you can just download mine.

2D Butterflies using the unity particle system tutorial image - butterfly

Now open a Unity project and import the spritesheet.

To get the sprites ready, select the spritesheet.

Change Sprite Mode to Multiple and Filter Mode to Point. Click Apply.

2D Butterflies using the unity particle system tutorial image - sprite

Now click the Sprite Editor button.

Slice the spritesheet using Grid By Cell Size (32 by 32 pixels in my case), then click Apply.

The individual sprites are now ready to use in the particle system.

2D Butterflies using the unity particle system tutorial image - slice

Open your scene and create a new particle system.

2D Butterflies using the unity particle system tutorial image - create

This is what the effect looks like.

2D Butterflies using the unity particle system tutorial image - 1

Change the shape to a box and set the scale to x = 10, y = 10, z = 10.

2D Butterflies using the unity particle system tutorial image - box

Change Max Particles to 10.

Change Start Speed to 0.

2D Butterflies using the unity particle system tutorial image - max

The particles will now look like this.

2D Butterflies using the unity particle system tutorial image - 2

Now let's make the particles look like butterflies.

We do this with the particle system's Texture Sheet Animation module.

Enable Texture Sheet Animation.

Change Mode to Sprites.

Add all the butterfly sprites from the sheet in the correct order so they play from the first frame to the last and then back to the first.

Change Time Mode to FPS.

Set FPS to around 10-15.

2D Butterflies using the unity particle system tutorial image - tex

You can now see butterflies instead of white particles.

2D Butterflies using the unity particle system tutorial image - 3

To make them flutter around, enable the Noise module.

2D Butterflies using the unity particle system tutorial image - noise

Now the effect looks much more natural.

2D Butterflies using the unity particle system tutorial image - 4

The effect is mostly done. You'll also want to increase the lifetime and add some color to the butterflies by changing the start color.

2D Butterflies using the unity particle system tutorial image - color
2D Butterflies using the unity particle system tutorial image - 5

If you enable Collision, the butterflies will also interact with objects around them.

2D Butterflies using the unity particle system tutorial image - coll

That way, the princess can interact with the butterflies in my game, which makes the effect feel much more alive than non-interactive background decoration.

And that's it for the tutorial. I hope you learned something new. Feel free to use this effect in your games!