Version: 2017.4
Creating a simple explosion
Particle System vertex streams and Standard Shader support

Creating exhaust smoke from a vehicle

Cars and many other vehicles emit exhaust smoke as they convert fuel into power. You can use Unity’s Built-in Particle System to add exhaust smoke as a nice finishing touch for a vehicle.

An exhaust generated by a particle system
An exhaust generated by a particle system

Timeline of a particle

Exhaust smoke emerges from the exhaust pipe quite fast but then rapidly slows down on contact with the atmosphere. As it slows, it spreads out and becomes fainter before it finally dissipates into the air. Since the exhaust gas is hot, it also rises slightly as it passes through the colder air surrounding it. Due to these factors, to create a realistic effect, a particle of exhaust smoke should observe the following rules over its lifespan:

  • It should begin no larger than the width of the pipe it spawns from and increases in size considerably over time.
  • It should begin partly transparent and fade to total transparency as it mixes with the air.
  • For its dynamics, the particle should begin quite fast but then slow rapidly. It should also rise slightly.

Implementation

Shape module

Firstly, set Shape to Cone and set the Angle property to 0. The “cone” this creates is actually a cylindrical pipe.

Next, for the Radius property, the value depends on the size of the vehicle’s exhaust pipe. The easiest way to make sure this matches the vehicle model’s exhaust pipe is to use the radius Gizmo in the Scene view. The radius determines quite a few things about the property settings you choose, such as the particle size and emission rate. This example assumes the vehicle is a car which follows Unity’s standard size convention of one world unit is equal to one meter; the radius is thus about 0.05, or 5cm.

Renderer module

For the smoke’s visuals, Unity’s Standard Assets package includes a suitable graphic for the smoke particle. If you don’t already have these installed, see Standard Assets.

With this package installed, go to the Renderer module and set the Material property to one of the ParticleSmoke Materials in the StandardAssets/ParticleSystems/Materials folder. For a dark smoke, use ParticleSmokeBlack and for a light smoke, use ParticleSmokeWhite.

Main module

The default lifetime of five seconds is generally too long for car exhaust fumes. To change this, and other general simulation properties, Open the main module. This is the module at the top of the Particle System component which has the same name as the GameObject. In this module: Set Start Lifetime to 2.5 seconds. Set Simulation Space to World. Using world simulation space allows the smoke to hang where it is produced even when the vehicle moves. Set Gravity Modifier to a small negative value. This example uses –0.1. The negative gravity effect causes the smoke particles to rise as if they are composed of hot gas. Finally, click the small menu arrow next to Start Rotation and select Random Between Two Constants. Set the two values to 0 and 360 respectively. This causes the smoke particles to have random rotations when they spawn. If you have many particles identically aligned, it is very noticeable and detracts from the effect of a random, shapeless smoke trail.

Color over Lifetime module

At this stage, the smoke particles are starting to look realistic and the default emission rate creates a nice “chugging” effect of an engine. The next thing to add it dissipation over time. To do this: Enable and open the Color Over Lifetime module. Click the Color property’s color picker. In the Gradient Editor window, click the top stop on the right-hand side of the gradient and set the alpha to 0. The top stops control the alpha and the bottom stops control the color. You should now see the smoke particles fading out in the Scene. Depending on how clean the engine is, you may want to reduce the alpha value of the gradient at the start; thick, dark smoke tends to suggest dirty, inefficient combustion.

Size over Lifetime module

As well as fading, the smoke should also increase in size. To do this: Enable and open the Size Over Lifetime module. Click the Size curve and, in the curve editor at the bottom of the Inspector, move the handle at the left-hand side vertically to make the particles start at a fraction of their full size. The exact size you choose depends on the size of the exhaust pipe but a value slightly larger than the pipe gives a good impression of escaping gas. Finally, use the simulation of the particle system in the Scene view to get a good visual impression of how the smoke looks. You may want to change the Start Size in the main module if the smoke doesn’t disperse far enough to create the effect you want.

Force over Lifetime module

Finally, the smoke should also slow down as it disperses. To do this: Enable and open the Force over Lifetime module. Set Space to Local. Set the Z component of the force to a negative value to indicate that the force should push particles back (the system emits particles along the positive Z direction in the object’s local space). This example uses a value of –0.75 because it works quite well with the properties set up as above.

Usage

After you position the exhaust particle system, firstly, make it a child GameObject of the main vehicle. This makes it move with the vehicle. For simple applications that only require the effect to play with no alterations, you can enable the Play On Awake and Looping properties. However, you may want to vary properties, like the emission rate, as the vehicle moves. Changing the emission rate helps with authenticity because an engine produces more smoke as it works harder, but it also helps to prevent the smoke particles from being spread out as the vehicle moves. A fast-moving vehicle with too low an emission rate will appear to produce distinct “puffs” of smoke, which is highly unrealistic.

You can vary the emission rate very easily from a script. If you have a variable in the script that represents the engine revs or the speed of the vehicle then you can simply multiply this value by a constant and assign the result to the ParticleSystem’s emissionRate property.

    // C#

    using UnityEngine;
    using System.Collections;

    public class PartScriptTestCS : MonoBehaviour {

        public float engineRevs;
        public float exhaustRate;

        ParticleSystem exhaust;


        void Start () {
            exhaust = GetComponent<ParticleSystem>();
        }
    

        void Update () {
            exhaust.emissionRate = engineRevs * exhaustRate;
        }

    }

Further Ideas

The basic scheme creates quite a convincing impression of exhaust smoke but you may notice that the “character” of the engine changes as you change the particle system’s properties. A poorly tuned, inefficient engine tends to burn its fuel incompletely which results in heavy, dark smoke that persists for a long time in the air. This is perfect for an old farm tractor, but not for a high-performance sports car. For a “clean” engine, use small values for the lifetime, opacity, and size increase of the particles. For a “dirty” engine, increase these values and perhaps use the Bursts property of the Emission module to create the impression of the engine spluttering.

Creating a simple explosion
Particle System vertex streams and Standard Shader support
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961