This is Part 1 of a multi-part series.

Part 2 is coming soon.

The particle system is a very fun and creative tool in unity from which you can make different motion graphic effects useful for the game environment and different kinds of effects that need multiple elements you need to show in a game.  

One of the many effects you can make by using a particle system is a galaxy that keeps spinning along with some stars and clusters of stars, which is what I am going to show you in this blog while explaining the usage of parameters and their description.

To make a particle system of a galaxy, I will be using the following 3 images.

This image has a little bit of fog and some stars on it. It is used for increasing the number of stars and giving a foggy feeling to the galaxy.
This is a single star image used as the main stars of the galaxy
this is used as the center of the galaxy

NOTE: All the 3 of the images I have used do not have a black background in the project. I added the background to make sure that you see the images clearly.

First, open a new unity project (2D or 3D). Then from the hierarchy right click and create a particle system.

Then you will get a particle system. Reset the position of the particle system to 0,0,0

After that, let's play around with the variables in the particle system according to what we need.

First, we need to give shape to the galaxy. It looks like a circular rotating disk-like structure with arms of stars, so let's modify the shape of our particle system into a circle from the Shape modifier of the particle system.

Default of the shape modifier
Change to circle
Final result

Now, we got the particle system going in a circular/flat spread.  

Since a galaxy rotates let's give the particle system a radial velocity from the Velocity over Lifetime modifier.

  1. Turn on Velocity over Lifetime  parameter.
  2. Give Orbital velocity on Z-axis as per we need. This parameter applies orbital velocity to the particles which make them rotate around the centre of the system. So, in our case let's give an orbital velocity on the z-axis the value of 4.
  3. Give a Radial value of 4. This parameter decides how far the particles will be thrown out while rotating around the centre of the particle system.

Let's see the result.

After following the above steps you will get this result

We can see that the particles are rotating around the centre which is a bit of what stars of the galaxy do, but we cannot see the arms that a galaxy has, so to get that effect we need to reconfigure how the particles are thrown out from the centre.

Thus, we need to make changes to the Shape modifier. Set the Spread parameter to 0.5. This will make our particle system emit the particles from two ends and divide the particles to emit into two sides. Let's see what change can it bring to the system.

In the centre, the particles are divided to emit from two sides

Since we have a small number of particles we cannot see the effect clearly. So lets increase the number of particles in the particle system from the Emission modifier. This modifier helps to create more or fewer particles in the particles system as needed.

Set the Rate over time in Emission modifier to 70.

result of setting the emission

As we can see, in the centre of the particle system, the particles are being pushed outwards more and then they nearly merge with the other arm of the particle system, the arms are also uneven due to the initial outward push of the particles from the centre. We have only set the radial velocity over lifetime of the particle system but where does this initial push of the particles come from?

This is due to the Start speed parameter of the particle system which is set by default while creating the particle system.  So, let's set the Start speed to 0 and see the result.

after setting the start speed to 0

Now, we can see a bit of the shape and rotation similar to a galaxy in the particle system that we made. But the overall radius is too big. To tackle the problem, we must know, why is the radius so big?

The radius of our galaxy particle system is big because the particles that are born from the centre of the particle system do not die for a longer time, i.e they remain active for a long time. Obviously, if they disappear sooner then the radius of the galaxy will become smaller. To make them disappear faster we must set the parameter of Start Lifetime the particles system to a smaller value.
By default,  Start Lifetime the particle system is set to 5. So, let us try to reduce the lifetime and give it a value of 2 and see what happens.

we can see that the galaxy becomes smaller after setting a small "start lifetime"

Now that we got the size and rotation for our galaxy we have to tackle yet another problem, i.e. the galaxy rotates too fast! There is a simple and fast fix for this, it is to set the parameter Simulation Speed to a small value. Normally simulation speed has default value of 1 which is considered a normal value for particle systems, we need a much slower simulation speed so let's put it to be 0.1 and see the difference.

different simulation speed results

Thus we have our basic model for a galaxy without using any materials and extra colours or other variables. The rest of the lesson will be on Part 2 of this blog. Thank you!