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.
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.
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!