Shuriken Particle Effects in Unity

Unity Particles

Unity Particles

In this article I will introduce the Shuriken Particle System that was added to Unity in version 3.5.

 

Introduction

Particle effects are an integral component of a polished video game. They add that extra flash, fizzle, and pop that makes a good game a great game. When used correctly particle effects can add that subtle bit of realism that draws the player into the game allowing them to feel, see, and maybe even smell your gameplay.

In Unity (and throughout this document) the terms Particle System and Particle Effect are used interchangeably however these two terms have different meanings.

  • Particle System: This is a single Particle System component that is attached to a GameObject.
  • Particle Effect: This refers to a hierarchical composition of GameObjects each with their own Particle System component. In other words, a combination of Particle Systems which together compose a Particle Effect.

Particle System

The component that provides the Shuriken Particle System functionality in Unity is the Particle System component. You can add a particle system to your scene in multiple ways.

  • Create a Particle System GameObject.
  • Create a GameObject and add the Particle System component.

Particle System GameObject

To create a Particle System in your scene, you can either create a new Particle System GameObject by selecting GameObject > Create Other > Particle System from the main menu.

Unity - Create New Particle System

Unity – Create New Particle System

Particle System Component

You can also create an empty GameObject in the scene and add a Particle System component to it by selecting Component > Effects > Particle System from the main menu.

Unity - Particle System Component

Unity – Particle System Component

Particle System Properties

Using either method should create a GameObject with a Particle System component attached to it. In the Inspector you will see the default particle system component.

Unity - Particle System Inspector

Unity – Particle System Inspector

I will discuss the individual modules in a later section.

Preview Panel

When you select a GameObject that has a Particle System component attached to it, the Particle Effect Preview Panel will appear in the Scene view.

Unity - Particle Effect Preview Panel

Unity – Particle Effect Preview Panel

The Particle Effect Preview Panel allows you to Pause, Simulate, and Stop the particle effect simulation in the Scene view.

While the Particle Effect is being simulated or paused, you can also change the value of the Playback Time to see how the particle effect will appear at certain times. It is also possible to scrub the Playback Time so that you can see how the Particle Effect changes over time.

Particle Effect View

You can open the Particle Effects view by selecting Window > Particle Effect from the main menu or by clicking the Open Editor… button on the Particle System component in the Inspector.

Unity - Open Particle Effect View

Unity – Open Particle Effect View

The Particle Effect view should open and display the Particle System component of the currently selected GameObject.

Unity - Particle Effect View

Unity – Particle Effect View

If you select a GameObject in the Scene view or the Hierarchy view that does not have a Particle System component then the Particle Effect view may be empty.

The Particle Effect view consists of three primary panels:

  • Toolbar: Provides buttons to Simulate/Pause and stop the Particle Effect in the Scene view
  • Particle System Editor: Provides access to the properties of the Particle System components.
  • Curve Editor: Allows you to manipulate the values of the Particle System properties using curves.

Toolbar

The toolbar at the top of the Particle Effect view allows you to control a few aspects of the Particle Effect displayed in the scene view as well as the layout of the different panels in the Particle Effect View.

Unity - Particle Effect View Toolbar

Unity – Particle Effect View Toolbar

Preview Controls

The Pause/Simulate and Stop buttons on the toolbar in the Particle Effect view allow you to start and stop the Particle Effect simulation in the Scene view and the Game view. These buttons operate exactly the same way as the Particle Effect Preview Panel that appears in the Scene view when a GameObject with a Particle System component is selected.

Show All/Selected

The Show: All/Selected button will toggle the view of the particle systems shown in the Particle Effect view and in the Scene view. With Show: All selected, all of the Particle System components will be visible in the Particle Effect view and in the Scene view. With Show: Selected selected, only the currenlty selected Particle System component will appear in the Scene view and the other Particle System components will appear darker in the Particle Effect view.

Unity - Particle Effect View  (Show All)

Unity – Particle Effect View (Show All)

Unity - Particle Effect View  (Show Selected)

Unity – Particle Effect View (Show Selected)

You will still be able to make changes to the other Particle System components in the Particle Effect view but they will not be visible in the Scene view or the Game view and the Particle System component will appear dimmed in the Particle Effect view.

In addition, the currently selected Particle System component will display a blue outline to indicate that it is the currently selected Particle System (as shown in the images above).

Resimulate

If the Resimulate toggle button is enabled the the Particle Effect will be updated when changes to the Particle System properties are made and those changes will be immediately visible in the Scene view. If this option is not selected then you must manually resimulate the Particle Effect to see the changes you made.

Wireframe

The Wireframe toggle button to preview the Particle Effect in the Scene view with wireframes turned on for the billboard and mesh particles. In addition to the wireframe for the particles, the screen-space bounding box for each Particle System is also displayed in the Scene view.

Unity - Particle Effect View (Wireframe)

Unity – Particle Effect View (Wireframe)

Layout

The Layout button allows you to swap between a horizontal layout and a vertical layout. Using the horizontal layout the Particle System components will appear in the left panel and the Curve Editor will appear in the right panel. Using the vertical layout the Particle System components will appear in the top panel and the Curve Editor will appear in the bottom panel.

Unity - Particle Effect View (Horizontal Layout)

Unity – Particle Effect View (Horizontal Layout)

Unity - Particle Effect View (Vertical Layout)

Unity – Particle Effect View (Vertical Layout)

Lock Selected

The Lock Selected toggle button will keep the currently selected Particle Effect visible in the Particle Effect view even if you change the currently selected GameObject in the Scene view or the Hierarchy view.

Curve Editor

The Curve Editor is used to manipulate the curves for specific properties of the Particle System components.

Unity - Particle Effect Curve Editor

Unity – Particle Effect Curve Editor

In the image above, the Start Size property of the Flare Particle System is selected and viewable in the Curve Editor.

Numeric Properties

The Particle System components have several properties that can have a scalar numeric value (such as the Duration and Start Delay properties), or a boolean value (such as the Looping and the Prewarm properties) but there are also a few properties that allow you to select the value type of the property using the drop-down arrow shown to the right of the property (such as can be seen on the the Start Lifetime, Start Speed, and Start Size properties).

Unity - Particle System Property Type

Unity – Particle System Property Type

There are different options in this drop-down menu depending on whether you are editing a numeric property or a color (or gradient) property.

For numeric properties you can change the type of the value to one of the following types:

  • Constant: Choose a single numeric value that will be used over the entire duration of the Particle System simulation or over the entire lifetime of the particle (depending on the selected module)
  • Curve: The value of the property will be determined by a value on a curve at the time during the Particle System simulation or at a time during the lifetime of the particle (depending on the selected module).
  • Random Between Two Constants: Allows you to specify a minimum and maximum value that will used to select a random value between those two points.
  • Random Between Two Curves: Unity will create a random curve that lies between the minimum and maximum curves. The current value will be chosen based on the current time of the Particle System simulation or the lifetime of the particle depending on the selected module.

Constant

If a numeric property has a Constant value type then the value of the property will not change over the duration of the Particle System simulation or the lifetime of the particle. No curve will be visible in the curve editor in this case. For example, the Start Lifetime property is set to be a Constant value.

Unity - Particle System Numeric Property (Constant)

Unity – Particle System Numeric Property (Constant)

A Constant property will not be displayed in the Curve Editor.

Curve

If a numeric property has a Curve value type then the value of the property will be determined by the value of the curve (displayed in the curve editor) at a specific time during the simulation of the Particle System or at the lifetime of the particle (depending on the module).

Unity - Particle System Numeric Property (Curve)

Unity – Particle System Numeric Property (Curve)

The image above shows the Start Size property is selected and its Curve property is shown in the Curve Editor.

Random Between Two Constants

If a numeric property is set to a Random Between Two Constants type then the value of the property will be a random value between a minimum and maximum values.

Unity - Particle System Numeric Property (Random Between Two Constants)

Unity – Particle System Numeric Property (Random Between Two Constants)

In the image above the Start Lifetime property is set to a Random Between Two Constants with a minimum value of 0 and a maximum value of 0.05.

If you select a Random Between Two Constants then there will not be a graph in the Curve Editor for that property.

Random Between Two Curves

If a numeric property is set to a Random Between Two Curves then the value of the property will be determined by a randomly generated curve that fits within the minimum and maximum curves.

Unity - Particle System Numeric Property (Random Between Two Curves)

Unity – Particle System Numeric Property (Random Between Two Curves)

In this image the Start Lifetime property is shown with a minimum and maximum curve. The shaded area between the two curves is the area in which the randomly generated curve will exist.

Color Properties

Some properties of the Particle System do not use numeric values but instead use colors or gradients. For example, the Start Color property allows you to specify a color as it’s value.

Similar to numeric properties, color properties can be one of the following types:

  • Color: Use a single color over the duration of the Particle System simulation or the lifetime of the Particle depending on the module.
  • Gradient: Use a gradient to specify the color value over the duration of the Particle System simulation or the lifetime of the Particle depending on the module.
  • Random Between Two Colors: A random color is chosen between two color values.
  • Random Between Two Gradients: A random gradient is chosen between two gradient values.
Unity - Particle System Color Property

Unity – Particle System Color Property

Color properties never use the Curve Editor. Instead, colors use the Color Picker and gradients use the Gradient Editor.

Color

If you specify that a color property should be a single Color value, then you will use the Color Picker to determine the color of the property over the duration of the Particle System simulation or the lifetime of the particle depending on the module.

Unity - Particle System Color Property (Color)

Unity – Particle System Color Property (Color)

Gradient

If you specify that a color property should be a Gradient value, then you will use the Gradient Editor to determine the color of the property over the duration of the Particle System simulation or the lifetime of the particle depending on the module.

Unity - Particle System Color Property (Gradient)

Unity – Particle System Color Property (Gradient)

Random Between Two Colors

The Random Between Two Colors type allows you to specify two color values. The color that is chosen is a random color that lies somewhere between these two colors.

Unity - Particle System Color Property (Random Between Colors)

Unity – Particle System Color Property (Random Between Colors)

Random Between Two Gradients

The Random Between Two Gradients type allows you to specify two gradients. The color of the property is determined by a random gradient that is created based on the two gradients.

Unity - Particle System Color Property (Random Between Two Gradients)

Unity – Particle System Color Property (Random Between Two Gradients)

Particle System Modules

Each Particle System consists of several modules that are shown in the Inspector and in the Particle Effect view. Each module controls different aspects of the Particle System.

The following modules are available to each Particle System component:

  • Initial Module: Defines properties that are used to initialize the particles. This module cannot be disabled.
  • Emission Module: Controls the emission rate of particles.
  • Shape Module: Defines the shape of the particle emitter.
  • Velocity over Lifetime Module: Used to control the velocity of the particles over their lifetime.
  • Limit Velocity over Lifetime Module: Limits the speed of the particles over their lifetime.
  • Force over Lifetime Module: Applies a force to the particles over their lifetime.
  • Color over Lifetime Module: Adjusts the color of the particles over their lifetime.
  • Color by Speed Module: Adjusts the color of the particles based on their speed.
  • Size over Lifetime Module: Controls the size of the particles over their lifetime.
  • Size by Speed Module: Controls the size of the particles based on their speed.
  • Rotation over Lifetime Module: Adjusts the particles angular velocity (rate of rotation) over their lifetime.
  • Rotation by Speed Module: Adjusts the particles angular velocity (rate of rotation) based on their speed.
  • Collision Module: The collision module uses a set of transforms that define collision planes for which the particles will collide with.
  • Sub Emitters Module: Allows the creation of other particle systems during particle birth, death, and collision.
  • Texture Sheet Animation Module: Allows you to define a sprite sheet that will be used to animate the texture of the particles over their lifetime.
  • Renderer Module: Defines the properties that are required to visually render the particles (such as the particle’s Material).

Initial Module

The Initial Module is always present on every Particle System and it cannot be removed or disabled. This module controls how each particle is initialized when it is emitted.

Unity - Particle System Modules (Initial)

Unity – Particle System Modules (Initial)

The Initial Module defines the following properties:

  • Duration: The duration in seconds that the particle system will emit particles.
  • Looping: If you need the particle system to keep emitting particles even after the duration, then set this property to true.
  • Prewarm: If the Particle System is set to Looping then enabling this parameter will cause the particle system to appear that it has already emitted particle for one cycle when it is created. This is useful for effects like fountains and waterfalls where a warm-up cycle would be visible to the player. Only looping Particle Systems can be prewarmed.
  • Start Delay: The delay in seconds before this particle system will start emitting particles. Particle Systems that are both Looping and Prewarm cannot have a Start Delay value and in such a case this property will be disabled.
  • Start Lifetime: The lifetime in seconds of the particles from the time that they are emitted.
  • Start Speed: The initial speed of the particle when it is emitted.
  • Start Size: The initial size of the particle when it is emitted.
  • Start Rotation: The initial rotation of the particle measured in degrees when it is emitted.
  • Start Color: The initial color of the particle when it is emitted.
  • Gravity Modifier: The global gravity vector is first multiplied by this value before being applied to the particles. To make particles move upwards (useful for smoke) make this value negative.
  • Inherit Velocity: How much of the linear velocity of the Particle System’s Transform node is used to determine the initial velocity of the particle. This is used to simulate conservation of momentum. This only has an influence if the Particle System GameObject is moving.
  • Simulation Space: Should the particle be simulated relative to Particle System Transform (Local space) node or relative to the origin of the world (World space).
  • Play On Awake: Should the Particle System automatically start emitting particles as soon as it is created.
  • Max Particles: The maximum number of particles that this Particle System will ever have at any moment.

Emission Module

The Emission Moduele defines the rate at which particles are emitted from the Particle System. The Emission Module also allows you to define particle bursts when a large number of particles are emitted at certain intervals over the duration of the Particle System simulation.

Unity - Particle System Modules (Emission Module)

Unity – Particle System Modules (Emission Module)

The Emission Module defines the following properties:

  • Rate: The number of particles that are emitted. If the nameless drop-down parameter under Rate is set to Time then this parameter determines the number of particles that are emitted per second. If the drop-down parameter is set to Distance then this parameter determines the number of particles that are emitted per world unit (per meter).
  • Burst: The Burst parameter allows you to specify specific intervals at which extra particles should be emitted. The Time of the burst is measured in seconds since the particle simulation started. The Particles property determines that number of particles that will be emitted at that time. Burst intervals can be added and removed using the (+) and (-) buttons next to the burst parameter.

Shape Module

The Shape Modules determines the shape of the area that emits particles. The properties that appear here are determined by the Shape parameter.

The Shape parameter can have one of the following values:

  • Sphere: The shape of the emitter resembles a 3D sphere.
  • Hemisphere: The shape of the emitter resembles a half-sphere. The hemisphere is always in the local positive Z axis (relative to the GameObject)
  • Cone: The shape of the emitter resembles a cone. The cone is always in the direction of the local positive Z axis.
  • Box: The shape of the emitter resembles a 3D box.
  • Mesh: Particles will be emitted from either the vertex, edge, or triangles of a mesh. The mesh can either be an asset in the project folder or a mesh that has been placed in the scene (via a GameObject).

Sphere

The Sphere shape emitter defines a 3D sphere that defines the shape of the area in which particles are emitted.

Unity - Particle System Modules (Shape Module - Sphere)

Unity – Particle System Modules (Shape Module – Sphere)

The Sphere Shape emitter has the following properties:

  • Radius: The radius of the sphere in world units.
  • Emit from Shell: If checked, then particles will only be emitted from the shell of the sphere (at a distance exactly equal to Radius from the origin of the Particle System). Otherwise, particles will be emitted randomly at a distance less than the Radius from the origin of the Particle System.
  • Random Direction: If checked particles will be emitted in random directions. Otherwise particles will be emitted outward from the center of the sphere.

HemiSphere

The HemiSphere shape emitter will emit particle in the shape of a half-circle. The HemiSphere is always in the direction of the local Z-axis.

Unity - Particle System Modules Shape Module - HemiSphere)

Unity – Particle System Modules Shape Module – HemiSphere)

The HemiSphere Shape emitter has the following properties:

  • Radius: The radius of the hemi-sphere in world units.
  • Emit from Shell: If checked, then particles will only be emitted from the shell of the hemi-sphere (at a distance exactly equal to Radius from the origin of the Particle System). Otherwise, particles will be emitted randomly at a distance less than the Radius from the origin of the Particle System.
  • Random Direction: If checked particles will be emitted in random directions. Otherwise particles will be emitted outward from the center of the hemi-sphere.

Cone

The Cone shape emitter defines a cone that has its apex at the origin of the ParticleSystem and is in the direction of the positive local Z-axis. Particles are emitted at a random angle from the apex of the Cone in the direction of the positive local Z-axis..

Unity - Particle System Modules (Shape Module - Cone)

Unity – Particle System Modules (Shape Module – Cone)

The Cone shape emitter has the following properties:

  • Angle: The maximum angle that particle will be emitted in the direction of the Cone.
  • Radius: This parameter allows you to determine the radius of the apex of the Cone. A radius of 0 indicates the particles will be emitted exactly at the apex of the Cone. A larger radius will enlarge the apex in which particles can be emitted.
Unity - Particle System Module (Cone Emitter)

Unity – Particle System Module (Cone Emitter)

The image shows a Cone shape emitter. The smaller end of the cone is called the apex and the larger part of the cone is called the base. The length of the cone is determined by the Start Speed parameter of the Initial Module. The particles are only emitted from the apex of the cone.

Box

The shape of the emitter will resemble a 3D box. The box will always be orientated according to the orientation of the Particle System‘s Transform node. Particles will be emitted at a random position within the volume of the box.

Unity - Particle System Modules (Shape Module - Box)

Unity – Particle System Modules (Shape Module – Box)

The Box shape emitter has the following properties:

  • Box X, Y, Z: The size of the box measured in world-units in each the X, Y, and Z axis.
  • Random Direction: If checked particles will be emitted in random directions. Otherwise particles will be emitted in the direction of the local Z-axis.

Mesh

The Mesh shape emitter allows you to specify a mesh that determines the area in which the particles are emitted. You can specify that the particles should be emitted at a random vertex, edge, or triangle face of the mesh.

Unity - Particle System Modules (Shape Module - Mesh)

Unity – Particle System Modules (Shape Module – Mesh)

The Mesh shape emitter has the following properties:

  • Vertex, Edge, Triangle: This drop-down box determines how the particles are emitted from the mesh. Vertex specifies that the particles will be emitted at a random vertex of the mesh. Particles will be emitted in the direction of the vertex normal. Edge specifies that the particles will be emitted at a random edge (an edge connects any two vertices) on the mesh. Particles will be emitted at an interpolated directed based on the direction of the vertex normals of the two vertices that define the edge. Triangle specifies that particles will be emitted from the triangle faces of the mesh. Particles will be emitted in the direction of the face normal for that triangle.

Velocity over Lifetime Module

The Velocity over Lifetime module allows you to animate the velocity of the particle over its lifetime.

Unity - Particle System Modules (Velocity over Lifetime)

Unity – Particle System Modules (Velocity over Lifetime)

The Velocity over Lifetime has the following properties:

  • X, Y, Z: The direction of the velocity vector. These values can be either a Constant, Curve, Random Between Two Constants, or a Random Between Two Curves.
  • Space: Whether the velocity vector is expressed in Local-Space or World-Space.

Limit Velocity over Lifetime Module

The Limit Velocity over Lifetime module allows you to restrict the maximum velocity or speed of the particle over it’s lifetime.

Unity - Particle System Modules (Limit Velocity over Lifetime)

Unity – Particle System Modules (Limit Velocity over Lifetime)

The Limit Velocity over Lifetime module has the following properties:

  • Separate Axis: If enabled, then the next parameter will be the X, Y, and Z axis of maximum velocity the particle can have before being dampened. Otherwise the next parameter will be Speed which is used to limit the maximum magnitude of the particles velocity vector.
  • X, Y, Z: If Separate Axis is enabled then these values represent the X, Y, and Z axis of the maximum velocity vector.
  • Speed: If Separate Axis is not enabled then the Speed parameter determines the maximum magnitude of the particle’s velocity vector.

Force over Lifetime Module

The Force over Lifetime module is used to apply a force to the particle that will effect it’s velocity. This can be used to create turbulent particle for example sparks from a fire or snowflakes that are influenced by wind.

Unity - Particle System Modules (Force over Lifetime)

Unity – Particle System Modules (Force over Lifetime)

The Force over Lifetime module has the following properties:

  • X, Y, Z: The X, Y, and Z components of the force vector to apply to the particle. This value can be either Constant, Curve, Random Between Two Constants, or a Random Between Two Curves.
  • Space: Determines whether the force vector is expressed in Local-Space or World-Space.
  • Randomize: If enabled, the magnitude of the force vector will be randomized. This parameter only becomes available if the force parameter is set to either Random Between Two Constants or Random Between Two Curves.

Color over Lifetime Module

The Color over Lifetime module allows you to specify the color of the particle over it’s lifetime.

Unity - Particle System Modules (Color over Lifetime)

Unity – Particle System Modules (Color over Lifetime)

This module only has a single parameter called Color which can be either a Gradient or a Random Between Two Gradients.

For example, the following gradient will cause the particle to start as a red particle and transition through all of the colors of the rainbow and fade-out over the last 25% of it’s life.

Unity – Gradient Editor

Color by Speed Module

The Color by Speed module will adjust the color of the particle based on its speed (the magnitude of the velocity vector).

Unity - Particle System Modules (Color by Speed)

Unity – Particle System Modules (Color by Speed)

The Color by Speed module has the following properties:

  • Color: Defines a gradient that will be used to determine the color of the particle based on its speed. This value can be a Gradient or a Random Between Two Gradients
  • Speed Range: Used to map the speed of the particle to a color. If the particle has a minimum speed it will map to the color of the gradient at 0%. If the particle has the maximum speed then then it will map to the color of the gradient at 100%.

For example, the following gradient will cause the particle to turn red as it approaches the maximum speed.

Unity - Gradient Editor

Unity – Gradient Editor

Size over Lifetime

The Size over Lifetime module allows you to control the scale of the particle over it’s lifetime.

Unity - Particle System Modules (Size Over Lifetime)

Unity – Particle System Modules (Size Over Lifetime)

The Size over Lifetime module defines a single parameter that can be either a Curve, Random Between Two Constants, or a Random Between Two Curves.

For with the curve shown in the image below will start the particles with a scale of 0 at the beginning of its lifetime and steadily scale to full size near the end of the particle’s lifetime.

Unity - Particle System Modules (Size Over Lifetime Curve)

Unity – Particle System Modules (Size Over Lifetime Curve)

Size by Speed

The Size by Speed module allows you to specify the scale of the particle based on its speed.

Unity - Particle System Modules (Size by Speed)

Unity – Particle System Modules (Size by Speed)

The Size by Speed module defines the following properties:

  • Size: The size of the particle based on its speed. This parameter can be a Curve, Random Between Two Constants, or a Random Between Two Curves.
  • Speed Range: Maps the maximum and minimum speeds to a value on the Speed curve.

Rotation over Lifetime Module

The Rotation over Lifetime module controls the angular velocity of the particle over its lifetime.

Unity - Particle System Modules (Rotation over Lifetime)

Unity – Particle System Modules (Rotation over Lifetime)

The Rotation over Lifetime module defines a single property called Angular Velocity. This property controls the rotation of the particle in degrees per second over the lifetime of the particle. This property can be a Constant, Curve, Random Between Two Constants, or a Random Between Two Curves.

Rotation by Speed Module

The Rotation by Speed module controls the angular velocity of the particle based on its speed (magnitude of the velocity vector).

Unity - Particle System Modules (Rotation by Speed)

Unity – Particle System Modules (Rotation by Speed)

The Rotation by Speed module defines the following properties:

  • Angular Velocity: Used to control the rotation of the particle in degrees per second based on its speed. This property can be a Constant, Curve, Random Between Two Constants, or a Random Between Two Curves.
  • Speed Range: Maps the minimum and maximum speeds to a value in the Angular Velocity property. If the Angular Velocity is a Constant then the Angular Velocity of the particle will be the same regardless of its speed.

Collision Module

The Collision module allows you to specify a set of Transform nodes that will be used to perform collision with the particles in this Particle System.

Unity - Particle System Modules (Collision)

Unity – Particle System Modules (Collision)

The Collision module defines the following properties:

  • Planes: The Planes property is an array of maximum 6 Transform nodes that are used to define the position and orientation of invisible planes in the scene. It is not necessary that the Transform that you assign in this list actually have a Plane mesh assigned to it. The local Y-axis of the Transform node is used to determine the normal of the plane (that is, the local Y-axis of the Transform node points up in the direction of the plane). You can add up to 6 planes to this list by pressing the (+) button and you can remove planes from the list by pressing the (-) button.
  • Dampen: How much of the speed of the particle is reduced when a collision occurs. A value of 0.5 will reduce the particle to half of its current speed. This property can have a value in the range 0 to 1.
  • Bounce: How much the particle will bounce. If this value is 1, then 100% of the particles vertical motion is maintained. If this value is 0 then it will not bounce at all. This parameter can have a value in the range 0 to 1.
  • Lifetime Loss: How much of the particle’s Start Lifetime is lost when a collision occurs. If you want the particle to die as soon as it collides then set this parameter to 1. This value can have a value in the range 0 to 1.
  • Visualization: The Visualization parameter will draw virtual planes in the Scene view and the Game view to help you determine where the planes are located relative to the Particle System. These planes will not be visible in the final game. This property can have the value Plane or Grid which determine how the virtual plane is rendered. Adjusting the Transform node that is used to define the plane will not update the virtual plane in the Scene view or the Game view (I think this is a bug).
  • Scale Plane: Determines the scale of the virtual plane.

Sub Emitters Module

The Sub Emitters module allows you to spawn additional particle systems when a particle is emitted (birth), or if it collides with a virtual plane, or on particle death.

Unity - Particle System Modules (Sub Emitters)

Unity – Particle System Modules (Sub Emitters)

The Sub Emitters module defines the following properties:

  • Birth: The Particle System to spawn when the particle is emitted.
  • Death: The Particle System to spawn when the lifetime of the particle reaches 0.
  • Collision: The Particle System to spawn when the particle collides with one of the virtual planes defined in Collision module.

If you assign a Particle System as a sub emitter of another Particle System then the assigned Particle System will not start playing when the Particle Effect is started. In addition to this, spawned Particle System will inherit the position of the particle which spawned it.

Texture Sheet Animation Module

The Texture Sheet Animation module allows you to animate the texture coordinates of the particle over its lifetime. This module uses the size of the texture assigned to the Material property of the Renderer module (discussed next) to determine the size of each tile of the sprite sheet.

This module allows you to create a sprite sheet of animated sprites that will be used to created animated textures for your particles.

Unity - Particle System Modules (Texture Sheet Animation)

Unity – Particle System Modules (Texture Sheet Animation)

The Texture Sheet Animation module defines the following properties:

  • Tiles: The number of tiles in the X and Y directions in the texture. For example, the value X = 2 and Y = 1 implies that there are 2 tiles per row and 1 row of tiles in the texture.
  • Animation: The tiles can be animated Whole Sheet or Single Row. If you specify Whole Sheet for this property then every tile in the texture will be used to animation the particle. Single Row means that the particle should be animated using only a single row of tiles in the texture.
  • Random Row: If checked, then one row of tiles will be chosen at random when the particle is emitted. This parameter is only available if Single Row property is chosen.
  • Row: If Random Row is not checked then this property determines the row in the texture to be used for the texture animation.
  • Frame over Time: Determines the frame to use over the lifetime of the particle. This property can be a Constant, Curve, Random Between Two Constants, or a Random Between Two Curves. To render each frame in sequence, use a linear increasing curve.
  • Cycles: How many times the animation will loop during the lifetime of the particle. This value must be a whole number.

For example, the following image contains a single row of 2 tiles:

Sparks (2x1)

Sparks (2×1)

Renderer Module

The Renderer module determines how the particles are rendered to the screen.

Unity - Particle System Modules (Renderer Module)

Unity – Particle System Modules (Renderer Module)

The Renderer module defines the following properties:

  • Render Mode: Determines how the particles are rendered. The Render Mode property can have one of the following values:
    • Billboard: The particle is rendered as a screen-aligned quad. That is, the particle will always face the viewer.
    • Stretched Billboard: The particle will be screen aligned and it will be stretched according to the additional properties:
      • Camera Scale: How much of the speed of the camera is taken into consideration when determining the stretching of the particle. Setting this parameter to 0 will not apply any additional stretching of the particle if the camera is moving.
      • Speed Scale: The additional scaling of the particle along the particles velocity vector. Setting this value to 0 will not apply any additional scaling along the velocity vector of the particle.
      • Length Scale: Scales the length of the particle relative to its width. A value of 1 implies the particle is square.
    • Horizontal Billboard: The particle will be aligned to a horizontal plane in world-space. The particles will seem to disappear when viewed from the side.
    • Vertical Billboard: The particle will be aligned a vertical plane in world-space. The particles will seem to disappear when viewed from above or below.
    • Mesh: Renders each particle as a mesh.
      • Mesh: The Mesh property becomes available if the Render Mode is set to Mesh. This property determines the Mesh to use to represent the particle. This can be a Mesh asset in the Project or a Mesh that has been assigned to a GameObject in the Scene.
  • Material: The Material that is used to render the particle.
  • Sort Mode: Sorts the particles within the Particle System. Particles should only be sorted when unsorted particles cause rendering artifacts.
    • None: The particles are not sorted.
    • Distance: Particles closer to the camera will be drawn after particles further away. This ensures that alpha blended particles will be rendered correctly.
    • Youngest First: Particles are sorted by age and older particles will be drawn over younger particles.
    • Oldest First: Particles are sorted by age and younger particles will be drawn over older particles.
  • Sorting Fudge: The Sorting Fudge property can be used to effect the draw order of Particle Systems. Particle Systems with a lower Sorting Fudge value will more likely be drawn last and thus appear in front of other transparent objects (including other particles).
  • Cast Shadows: If enabled, the particles in the Particle System will cast shadows. The particle must be rendered using an opaque material (no alpha blending). This is useful for Mesh emitters with non-transparent materials.
  • Receive Shadows: If enabled, then shadows will be cast on the particles in this Particle System. The particles must be rendered with opaque (non-transparent) material. This is useful for Mesh emitters with non-transparent materials.
  • Max Particle Size: Sets the maximum size a particle can be. This variable is expressed in normalized viewport size. Valid values for this parameter are in the range [0 - 1] where a size of 1 will allow a single particle to fill the entire viewport. The default value of 0.5 will limit the size of a particle to half the viewport size. This parameter can be used to help reduce fill-rate issues. If the frame-rate drops significantly when viewing the particle effect from close-up, consider reducing the value of this parameter.

Examples

Now that we have a understanding of the underlying components that makeup a Particle System let’s put our knowledge to good use and build a simple Particle Effect.

Flare

For this example, we will go through the steps to build a simple flare particle effect.

Open Unity and either create a new project or open an existing project.

Unity - Flare Particle Effect (1)

Unity – Flare Particle Effect (1)

Download the following Unity Package and import it into your project.

ParticleEffects.unitypackageParticleEffects.unitypackage

You can import this package into your Unity project by double-clicking on the package file or by selecting Assets > Import Package > Custom Package… from the Main Menu in Unity.

Unity - Import ParticleEffects package

Unity – Import ParticleEffects package

After you click the Import button, you should get the 3 textures imported into your project:

  • Flare_Diffuse: The diffuse texture for the flare Particle System.
  • Smoke_Diffuse: The diffuse texture for the smoke Particle System.
  • Sparks_Tiles: A tile texture that contains 2 tiles of spark textures.

After you import this package, your project might look like this:

Unity - Flare Particle Effect (2)

Unity – Flare Particle Effect (2)

Base Flare Particle System

Create a new Particle System GameObject by selecting GameObject > Create Other > Particle System from the Main Menu.

Unity - Flare Particle Effect (3)

Unity – Flare Particle Effect (3)

This Particle System will be the root of the Particle Effect. Rename this GameObject to Flare Particle Effect.

Open the Particle Effect view by selecting Window > Particle Effect from the Main Menu or click the Open Editor… button on the Particle System component in the Inspector view.

Unity - Flare Particle Effect (4)

Unity – Flare Particle Effect (4)

The first thing we’ll create are the Particle System that renders the sparks for our flare effect.

Set the following properties of the Initial Module:

  • Duration: 5.00
  • Looping: true
  • Prewarm: true
  • Start Lifetime: 0.05
  • Start Speed: 0
  • Start Size: Random Between Two Curves with a max curve at 1.0 and a minimum curve set to 0.5 as shown in the image below.

    Flare Particle - Start Size

  • Start Rotation: Random Between Two Curves with a max curve set at 180 and a min curve set at 0 as shown in the image below.

    Flare Particle - Start Rotation

  • Start Color: Random Between Two Colors:
    • First Color: White:
      • Red: 255
      • Green: 255
      • Blue: 255
      • Alpha: 255

      Unity - Color Picker (White)

    • Second Color: Light Orange:
      • Red: 255
      • Green: 198
      • Blue: 114
      • Alpha: 255

      Unity - Color Picker (light orange)

  • Gravity Modifier: 0
  • Inherit Velocity: 0
  • Simulation Space: Local
  • Play On Awake: true
  • Max Particles: 2

You should have something similar to what is shown below.

Unity - Flare Particle Effect (5)

Unity – Flare Particle Effect (5)

Next, make sure the Emission module is enabled and set the Rate parameter to 20. Make sure the units are set to Time.

Unity - Flare Particle Effect (6)

Unity – Flare Particle Effect (6)

Expand the Shape module and set the following properties:

  • Shape: Sphere
  • Radius: 0.01
  • Emit from Shell: false
  • Random Direction: false
Unity - Flare Particle Effect (7)

Unity – Flare Particle Effect (7)

For the next step, we need to create a new Material that will be used to render the particles for this Particle System.

Create a new Material in the Project view and call it Flare_Sparks.

Set the Shader to Particles > Additive and set the Tint Color to gray.

  • Tint Color: Gray
    • Red: 128
    • Green: 128
    • Blue: 128
    • Alpha: 128
    • Unity - Color Picker (Gray)

      Unity – Color Picker (Gray)

Particle Texture property to Sparks_Tiles(2×1) texture that you imported earlier. The Flare_Sparks material should look like this:

Unity - Flare_Sparks Material

Unity – Flare_Sparks Material

Return to the Particle System and expand the Renderer module and set the following properties:

  • Render Mode: Billboard
  • Material: Flare_Sparks
  • Sort Mode: None
  • Sorting Fudge: 0
  • Cast Shadows: false
  • Receive Shadows: false
  • Max Particle Size: 0.5
  • Unity - Flare Particle Effect (8)

    Unity – Flare Particle Effect (8)

    You may have noticed that the sparks don’t look right yet. This is because we are using a tiled texture but we did not specify that in the Particle System.

    Enable the Texture Sheet Animation module and set its properties to the following values:

    • Tiles:
      • X: 2
      • Y: 1
    • Animation: Whole Sheet
    • Frame over Time: Random Between Two Constants with a minimum value of 0 and a maximum value of 2.
    • Cycles: 1
    Unity - Flare Particle Effect (9)

    Unity – Flare Particle Effect (9)

    Smoke Particle System

    Create a nested Particle System by clicking the (+) button in the Particle Effect view or add a nested GameObject to the Flare Particle Effect GameObject in the scene and add a Particle System component to it.

    Unity - Flare Particle Effect (10)

    Unity – Flare Particle Effect (10)

    Set the properties of the Initial module to the following values:

    • Duration: 5
    • Looping: true
    • Prewarm: true
    • Start Lifetime: 5
    • Start Speed: 1
    • Start Size: Random Between Two Curves with a maximum curve set to 3.4 and a minimum curve set to 1.75 as shown in the image below.

      Unity - Smoke Particle System (Start Size)

    • Start Rotation: Random Between Two Curves with a max curve set at 180 and a min curve set at 0 as shown in the image below.

      Flare Particle - Start Rotation

    • Start Color: Dark-gary Color with the following components:
      • Red: 29
      • Green: 29
      • Blue: 29
      • Alpha: 255
      • Unity - Color Picker (Dark-Gray)

    • Gravity Modifier: -0.05
    • Inherit Velocity: 0
    • Simulation Space: Local
    • Play On Awake: true
    • Max Particles: 10000

    You should have something similar to what is shown below.

    Unity - Flare Particle Effect (11)

    Unity – Flare Particle Effect (11)

    Next, expand the Emission module and set its properties to the following values:

    • Rate: 5
    • Units: Time
    • Bursts:
      Time Particles
      0.00 1
      2.00 1
      2.50 1
    Unity - Flare Particle Effect (12)

    Unity – Flare Particle Effect (12)

    Enable the Shape module and set its properties to the following values:

    • Shape: Cone
    • Angle: 25
    • Radius: 0
    Unity - Flare Particle Effect (13)

    Unity – Flare Particle Effect (13)

    Instead of the smoke coming straight up, I would like the smoke to come out from the side. To modify the direction the Particle System is emitted, you must rotate the Transform node the Particle System is assigned to.

    Select the Smoke Particle System GameObject in the Hierarchy view and rotate the game object so that it’s local Z axis is pointing to the side as shown in the image below:

    Unity - Flare Particle Effect (14)

    Unity – Flare Particle Effect (14)

    Enable the Color over Lifetime module and set the Color property to a Gradient similar to the gradient shown in the image below.

    Unity - Smoke Particle System (Color over Life)

    Unity – Smoke Particle System (Color over Life)

    You should have something similar to what is shown below.

    Unity - Flare Particle Effect (15)

    Unity – Flare Particle Effect (15)

    Enable the Size over Lifetime module and set its Size property to a Curve resembling the curve shown below:

    Unity - Smoke Particle System (Size over Lifetime)

    Unity – Smoke Particle System (Size over Lifetime)

    This should result in something similar to what is shown below.

    Unity - Flare Particle Effect (16)

    Unity – Flare Particle Effect (16)

    Enable the Rotation over Lifetime module and set the Angular Velocity parameter to a Random Between Two Curves. Set the minimum curve to -15 and the maximum curve to +15 as shown in the image below.

    Unity - Smoke Particle System (Rotation over Lifetime)

    Unity – Smoke Particle System (Rotation over Lifetime)

    To render the Smoke particle let’s create a new Material using the Smoke_Diffuse texture that was imported from the Unity package. Call the new Material Flare_Smoke and set its properties to the following values:

    • Shader: Particles/Additive
    • Tint Color: White with 50% Alpha:
      • Red: 255
      • Green: 255
      • Blue: 255
      • Alpha: 128
    • Particle Texture: Smoke_Diffuse
    Unity - Flare Smoke Material

    Unity – Flare Smoke Material

    Expand the Renderer module and set its properties to the following values:

      Render Mode: Billboard
    • Material: Flare_Smoke
    • Sort Mode: Oldest First
    • Sorting Fudge: 0
    • Cast Shadows: false
    • Receive Shadows: false
    • Max Particle Size: 1

    This should result in something similar to what is shown below.

    Unity - Flare Particle Effect (17)

    Unity – Flare Particle Effect (17)

    The particle effect is already looking nice but lets add one more Particle System to our Particle Effect.

    Sparks Particle System

    For this particle system we will add some sparks that will emit from the center of the Particle Effect.

    Add one more Particle System by clicking the (+) button in the Particle Effect view while the Flare Particle Effect is selected in the Hierarchy view. You can also add another Particle System GameObject in the scene and parent it to the Flare Particle Effect and zero the position and rotation.

    Rename this new Particle System to Sparks Particle System.

    Unity - Flare Particle Effect (18)

    Unity – Flare Particle Effect (18)

    The the properties of the Initial module to the following values:

    • Duration: 5.00
    • Looping: true
    • Prewarm: true
    • Start Lifetime: 3
    • Start Speed: Random Between Two Curves with a minimum curve at 3 and a maximum curve at 5 as shown in the image below:
      Unity - Sparks Particle System (Start Lifetime)

      Unity – Sparks Particle System (Start Lifetime)

    • Start Size: Random Between Two Constants with a minimum value of 0 and a maximum value of 0.03.
    • Start Rotation: Random Between Two Curves with a minimum curve of -180 and a maximum curve of 180.
    • Start Color: Random Between Two Colors:
      • First Color: White
        • Red: 255
        • Green: 255
        • Blue: 255
        • Alpha: 255
        • Unity - Color Picker (White)

          Unity – Color Picker (White)

      • Second Color: Orange
        • Red: 255
        • Green: 144
        • Blue: 0
        • Alpha: 255
        • Unity - Color Picker (Orange)

          Unity – Color Picker (Orange)

    • Gravity Modifier: 1
    • Inherit Velocity: 0
    • Simulation Space: Local
    • Play On Awake: true
    • Max Particles: 10000

    You should have something similar to the image shown below.

    Unity - Flare Particle Effect (19)

    Unity – Flare Particle Effect (19)

    Expand the Emission module and set the Rate to 50 and the units to Time.

    Unity - Flare Particle Effect (20)

    Unity – Flare Particle Effect (20)

    Expand the Shape module and set it properties to the following values:

    • Shape: Sphere
    • Radius: 0.02
    • Emit from Shell: false
    • Random Direction: false
    Unity - Flare Particle Effect (21)

    Unity – Flare Particle Effect (21)

    Enable the Color over Lifetime module and set the Color property to a Gradient that resembles the gradient shown in the image below.

    Sparks Particle System (Color over Lifetime)

    Sparks Particle System (Color over Lifetime)

    You should have something similar to what is shown below.

    Unity - Flare Particle Effect (22)

    Unity – Flare Particle Effect (22)

    Enable the Color by Speed module. Set the Color property to a Gradient that matches the Gradient shown in the image below.

    Sparks Particle System (Color by Speed)

    Sparks Particle System (Color by Speed)

    And set the Speed Range property to 0 to 1.

    This should now look something like this:

    Unity - Flare Particle Effect (23)

    Unity – Flare Particle Effect (23)

    For the sparks, we’ll create a new Material called Flare_Flare.

    Set the Materials Shader property to Particles/Alpha Blended and set the Tint Color to gray with 50% alpha:

    Unity - Color Picker (Gray)

    Unity – Color Picker (Gray)

    Set the Material’s Particle Texture property to the Flare_Diffuse texture that you imported from the Unity package.

    Unity - Flare_Flare Material

    Unity – Flare_Flare Material

    Expand the Renderer module on the Sparks Particle System and set its properties to the following values:

    • Renderer Mode: Stretched Billboard
    • Camera Scale: 0
    • Speed Scale: 0.05
    • Length Scale: 1
    • Material: Flare_Flare
    • Sort Mode: None
    • Sorting Fudge: 0
    • Cast Shadows: false
    • Receive Shadows: false
    • Max Particle Size: 0.5

    You should have sometime similar to what is shown below:

    Unity - Flare Particle Effect (24)

    Unity – Flare Particle Effect (24)

    At this point, the Particle Effect is finished. You can save a Prefab of the Particle Effect in your Project view so that you can create instances of it easily later.

    There is one more effect I want to achieve and that’s to make the sparks do collision with the ground plane. This will allow the sparks to bounce off the ground and come to a rest before they fade away.

    To achieve this, add an empty game object in the scene. Zero the position and rotation of the new GameObject. Rename this new GameObject to Flare Collider or something similar.

    Select the Sparks Particle System and enable the Collision module and set its properties to the following values:

    • Planes: Flare Collider (The empty GameObject we just created)
    • Dampen: 0.5
    • Bounce: 0.75
    • Lifetime Loss: 0
    • Min Kill Speed: 0
    • Visualization: Solid
    • Scale Plane: 1.00

    If the Flare Particle Effect is at the same height as the Flare Collider GameObject, then move it up a bit in the Y-axis so it is above the virtual plane.

    You should now see the sparks from the flare bouncing off the virtual plane.

    Unity - Flare Particle Effect (25)

    Unity – Flare Particle Effect (25)

    Congratulations. Your particle effect is finished.

    Exercise

    Try to create your own interesting particle effects.

    References

    Unity Manual – Particle Systems

    You can download the ShurikenExamples.zip file that contains the Flare particle effect as well as several other interesting particle effects.

17 thoughts on “Shuriken Particle Effects in Unity

    • Hite,

      I am always thinking of new things I want to post but time has been very limited (since I started a masters course in addition to my full-time teaching job). But in the next year, I want to make some updated Unity 4 posts as well as shader programming in GLSL and DirectX (11). That’s planned for the next year anyways.

  1. Hi.I`m new in Unity and have question. Can i create splash effects?. Exemple airplane collide in water than created water splashes (but not with scripts) . Thnx.

    • GevS,

      I’m not sure you can do this without scripts. You will AT LEAST need to handle the OnCollisionEnter message in a script to trigger the splash particle effect.

      If you don’t like writing scripts, then maybe you want to check-out the visual scripting plugins that are offered on the Asset Store (uScript – Visual Scripting Tool). I haven’t used these myself, but maybe this is something for the less programmer-savvy Unity developers.

  2. Thanks
    I’m reading the book《Unity 3.x Game Development Essentials》, and found the new particle system I’m using is totally different,this tutorials really help 。

    • Khraft,

      This property specifies how big the particle can become relative to the screen size. So if you specify 1.0, the particle can fill the entire screen if you get the camera very close to the particle effect.

      A value of 0.5 is generally good (then no particle will fill more than 50% of the screen) but if you having fill rate issues (the frame-rate drops when you get close to the particle effect) you may want to decrease this value to 0.25.

  3. Thanks for the tutorial, it is very helpful.
    I have a question about the performance of the particle system on iOS, I am interested in the smoke system and I am trying to create a FOG effect using it, but when I brought the smoke system near to the main camera, the FPS went down significantly, I copied your smoke system to a new scene and when it was about 4 units away from the camera I got around 53 FPS (the game is running at 60 fps) as seen in the following snapshot:
    https://www.dropbox.com/s/rlnc8yvyqrzwqvy/2013-12-07%2011.30.12.png

    but when I moved the system closer , about 2 units from the camera the FBS went down to around 18 FPS:
    https://www.dropbox.com/s/idceuvwvumxybig/2013-12-07%2011.35.06.png

    When I tried the effect I am looking for, after changing the following:
    -Distance from Camera: 0.7 units
    -Start Lifetime: 31
    -Start Speed: 0.06
    -Shape: Box
    -Start Color: Alpha 24
    -Color over lifetime: disabled
    The FBS went down to 3 FPS:
    https://www.dropbox.com/s/1euhlys40jsex9v/2013-12-07%2011.52.38.png

    Do yo have an idea why that is happening, and if there is a way to achieve the fog effect with a descent performance.

    Thanks
    Khaled

    • Khaled,

      It sounds like you are having a fill-rate issue. You can specify in the particle effect that particles cannot exceed a certain size in screen space. In the particle system’s Renderer module, make sure the Max Particle Size parameter is 0.5 or less.

      Hope this helps.

      • Thanks for the response, I changed the start size curve to less than 0.5, and the size over life time to less than 0.5, which resulted in a good performance (around 60 FPS), but I didn’t get the effect I was after, I ended up with small buffs here and there, not the evolving smoke I was looking for.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>