Particle systems, continuation with healing effect

Last time I wrote a small tutorial how to create a simple smoke with Unity particle system and how it would be very easy to adjust the settings to create another type of effects. Now we modify the particle system so that with very small changes we can create a neat basic healing effect.

Let’s create a new GameObject and name it ie. HealingEffect or something you like. Add the ParticleSystem component into the newly created GameObject. (if you don’t remember how to do this, check the previous post)

Then if you remember what I wrote about the textures and seeing the effect of the texture, change the texture first. We are going to need a image of a cross or something similar. Green cross is very often used as “healing effect” throughout the gaming history so that’s what we use now. You can easily draw one if you don’t have one available.

So drag the texture under Unity’s assets. Unity prepares the texture as an asset if it’s running or when started the next time from that project. Create a material and add the newly created texture into the material. Set the Shader to particles additive or particles additive (soft).

Now change the material in the particle system. Whoa! You already have flying crosses. Rotate the particle system -90 degrees on X -axis. This way the particles flying vertically away from the origin.

Now we tweak few values so that the effect looks good.

1) Size over lifetime. Create a curve where start and end are smaller (say 50% depending on your texture) and 100% in the middle. This way the particles start small, grow in size to become smaller again.

2) Color over lifetime. Create a curve with white color and then change the start alpha to 0 so it’s fully transparent, add a control point around 25% where alpha should be 255 (full opaque), another control point around 75% with full opaque and set the end alpha to 0. This way the effect is full transparent at start, opaque in the middle and transparent in the end. This gives nice fade effect at the start and in the end.

Some of the base settings need adjustment as well. It all depends on your texture but I used 100 max particles, start lifetime of 2.05, start speed of 3.0, start size of 0.85. Set the emission and shape to your liking but emission rate should be pretty small like 3. Also keep the shape narrow so particles are not sprayed too wide.

I used the same scene as before but I added an untextured low poly dog and applied the healing effect on it. If you did everything correctly you should have something similar, something like this:

What do you think? Leave a comment!

How to create simple smoke in Unity3d

This is a very short and simple tutorial for creating simple smoke in Unity by using Shuriken particle system. Similar tutorials can be found from the YouTube and interwebs all over. Things you need to be able to complete this tutorial. Unity3d (my version is 4.6.2) but you can use older version as well as long it has the Shuriken particle system. I think it’s 3.5 and later. A painting program to create the texture what we will be using, or modifying an existing one. I am using Photoshop. You need some basic understanding of Unity, game objects and prefabs too.

The outlooks of the smoke will be very highly dependent on your texture and how you tweak the parameters in the particle system but this tutorial should give you basic understanding what parameters will do.

Steps:

1) Start with a new project and new scene. Basically when you start Unity you select folder and let unity to create a new project. I created mine with the 3D presets.

2) Create an new game object. Menu -> GameObject -> Create Empty

3) Add a new component into your newly created game object and select particle system. You can rename your game object i.e. “Smoke”. Now you should have a GameObject at the center of the screen (0,0,0) with a Shuriken particle system component attached to it.

Default particle system rotation is 0,0,0 which causes the particles fly horizontally. You might want to change this depending on your needs. Usually it’s good practice to have position and rotation to be set to 0,0,0 and control them from the code if needed. If you are sure you use this particle system just one way you can of course set position and rotation to the game object it self. If particle system is part of a larger entity then you might want to set the position and rotation according to the parented object. (i.e. space ship engine exhaust)

4) Texture and material. Start with the material and texture because you want to see the how parameters affect to the texture. With the default material it’s rather difficult to see what i.e. rotation over lifetime does.

So, create a material. Menu -> Assets -> Create -> Material. For the shader select “Particles Additive” or “Particles Additive Soft” depending on your texture. For the texture drag the texture from the Assets folder to the material. You can copy the texture to the Assets folder and Unity imports it automatically.

Small remarks regarding the texture. Ideal texture would be large enough to have some details and the smoke on the texture should be white. Do not have smoke on the edges of the texture because when rendered it will be visible. Try to create a texture where smoke is in the middle and not touching the edges of the texture. It might be a good idea to have the texture smoke gray scale, preferably white, so you can use the color in the particle system to tint the color for your preference.

5) Parameters:

Color over lifetime. At the end we need a fade, otherwise the smoke disappears instantly which is not realistic and does not look good. Values: at the start color should be white and full opaque. In the end color should be white with full transparency.

Size over lifetime. Depending on the texture you use it might be a good idea to start with the very small size at the start and full size at the end. While the color over lifetime also does fade together with this we have a small opaque texture at start and full size transparent texture at the end. You can use preset curves for the ease.

Size by speed. We can also control the size by the particles speed. Since we already control the size over life and we don’t control the speed that much this is now not needed.

Rotation over lifetime. This controls the rotation of the texture over lifetime. If you don’t use this the effect becomes very static since texture is not rotated. I used “Random Between two curves”. You can play with the values and keep the ones you like the most. On the X axis you have the lifetime and on Y axis the angular velocity. The higher value causes more rotation.

Rotation by speed. This also controls the rotation but by the speed. The Y -axis is the angular velocity and X -axis is the remapped speed range that you have used. I had mine from 0 to 1 so that at the start I have stronger velocity and towards the end it doesn’t rotate at all.

Rest of the parameters. There are multiple parameters in the particle system itself and try out different values for the lifetime, speed, size and so on. There are no correct values because a lot depends on your texture.

Last thing to do is to create a prefab out of the GameObject so that you can reuse and instantiate the prefab where it is needed. Menu -> Assets -> Create -> Prefab. Rename to i.e “Smoke”. Now drag and drop the smoke from your hierarchy view to the prefab in the Assets. Now you can delete the “Smoke” GameObject from your scene since everything is stored at the prefab. Remember to save project. NOTE: If you change the GameObject in the scene after this the changes are not reflected to the prefab unless you press apply from the GameObject next to prefab and save the project.

When you are done you should have a simple smoke particle system similar to this:

Here the particle system is part of Unity Terrain in a simple scene where it could be like a signal smoke or something similar. By changing the parameters it’s easily adjusted to i.e. a smoke coming from a building on fire etc.

What do you think? Leave a comment!