Version: 2020.3
Creating a simple explosion
Visual Effect Graph

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 SystemA component that simulates fluid entities such as liquids, clouds and flames by generating and animating large numbers of small 2D images in the scene. More info
See in Glossary
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 GizmoA graphic overlay associated with a GameObject in a Scene, and displayed in the Scene View. Built-in scene tools such as the move tool are Gizmos, and you can create custom Gizmos using textures or scripting. Some Gizmos are only drawn when the GameObject is selected, while other Gizmos are drawn by the Editor regardless of which GameObjects are selected. More info
See in Glossary
in the Scene viewAn interactive view into the world you are creating. You use the Scene View to select and position scenery, characters, cameras, lights, and all other types of Game Object. More info
See in Glossary
. 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 GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
. 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 ModifierA Particle System property that scales the gravity value set in the physics manager. A value of zero switches gravity off. More info
See in Glossary
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 SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary
. 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 InspectorA Unity window that displays information about the currently selected GameObject, asset or project settings, allowing you to inspect and edit the values. More info
See in Glossary
, 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 AwakeSet this to true to make an Audio Source start playing on awake More info
See in Glossary
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
Visual Effect Graph