Particle Systems – Part 3 (Unity’s Shuriken)

Graphics: Unity Engine

Language: C#

Source : Download

In the previous posts I discussed the basics of particles systems and I provided an example of how to build a simple 2D star field using XNA. In this article, I will discuss how to apply these concepts to Shuriken, the particle system that is part of the Unity Engine. As with previous articles it is not the objective of this article to give a tutorial on Shuriken, I will also assume an understanding of the Unity Engine. The goal of this article is to demonstrate that the basic concept that I explained in 2D using XNA is directly applicable to other frameworks and engines (for example Unity). In any case, if you are interested in knowing more about Unity or about Shuriken in particular I recommend you to read Will Goldstone’s Unity 3.x Game Development Essentials. If you already have some knowledge on Unity and want to know more about its particle system Shuriken, you can read the full detailed documentation that explains the usage of its modules.

Star field Particle System with Unity’s Shuriken from Stilghar on Vimeo.

In order to demonstrate, what can be achieved with Unity’s Shuriken I will follow the same example I created using XNA. I will recreate the star field particle system using Shuriken and try to improve it a bit (this time will be in 3D and I will add some more effects. The idea is to obtain something like the video above (best seen in full screen and HD).

Unity Shuriken basics

The Unity Engine, as other professional game engines, has a visual editor. For people familiar with 3D modelling software such as Maya or 3DS Max this will feel very familiar. The basic idea is that the engine allows the game developer to visually create the game objects in 3D space without the need to write the low level code that takes care of positioning, updating and rendering these. The Engine will take care many tasks (game loop, rendering, audio, networking…) freeing us to concentrate on coding the gameplay itself. These engines are a double edged sword and should be handled with care. What I mean is that while it frees us from the low level tasks it may be tempting for beginners to completely ignore this, therefore ignoring how video games work and never really learning.

Unity editor

Coming back to Unity, Shuriken works as part of the visual editor. In the image above you can see that I have Shuriken docked to the lower left corner and I have three particle systems that I have created open. The basic concept that I explained in the previous posts is directly applicable to Shuriken. A particle system in Unity’s Shuriken will also consist of an emmitter, particles and an associated behaviour. The difference now, is that we do not need to write any code (we can if we wish to) as all the design of the system can be done through the visual editor. We just need to tell Shuriken the emmitter and particle characteristics and the engine will take care of updating and rendering them.

This time, instead of only creating a particle system, I have used three particle systems together to create the desired effect: the star field background, some fast stars, and a nebula effect. One important thing to notice is that as I am now working in 3D, I have created the particle systems as child objects of the camera itself. Doing it this way has the advantage that no matter where the camera moves the effect will be visible in the same way. This is because its position is relative to the camera and not world coordinates. If you want to create a particle system in a particular position of the 3D world do not do this.

Star field

The first of the three particle systems that I have created is the star field. This one is the most similar to the one I created in the 2D XNA example but this time in 3D:


For this particle system I have used the following properties:


I have left all the other characteristics to the default value. As you can see I am following the example I did using XNA. I create the particles randomly with a color in between dark and light blue. Also the color over Lifetime changes so that they have a zero alpha value at the start to avoid them popping up directly in the screen. This time I also decrease their size over time using a soft curve. I do this to avoid having very big particles in front of the camera. As I am now working on 3D space and the particles are created in a hemisphere emmitter, some of the particles will go directly towards the camera meaning that we can have the effect of very big particles when they are near the camera. I am also using the default render setting and the default particle material and texture.

Fast Stars

The next particle system that I use will create the effect of passing fast stars. This time I create very few of them and modify the renderer to use the stretched billboard one with a value of 5 for the lenght. This means that the particles will look 5 times longer than their width. I have also changed the color to a shade of yellow. I use also a hemisphere emitter. The effect obtained is something like this:



Finally, I am adding a third particle system to simulate the effect of a nebula (an interstellar cloud of dust). For this system what I do is use a cone emmitter much closer to the camera and a material with a texture resembling smoke. I create the particles rather big, overlapping each other, with a color that varies over Lifetime in the red-blue shades. And also I give them a random start rotation and a very slow rotation over Lifetime to avoid that the effect looks too deterministic. Furthermore, the particles will be created in a loop but also a burst at 2 seconds is created. Again, this gives the impression that the effect is more random.


Complete Star field

When having all the three systems together I achieve the complete effect. A blueish starfield, with yellow shooting stars and redish nebulas!

You can grab the full source at the beginning of the article. Besides the scene with the system, you will also find that I have exported the particle system as a Unity package ready for you to import in any Unity project.


PS: I don’t forget that in the last article I mentioned that I would talk about peformance and configuration via XML. I thought it was more interesting to advance this article and leave that for a future one.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s