VFX in Unity: Getting Started

Learn how to create your own custom visual effects using Unity’s built-in Particle System. By Ken Lee.

5 (2) · 1 Review

Download materials
Save for later
Share
You are currently viewing page 2 of 4 of this article. Click here to view the first page.

Creating the Muzzle Effects

A muzzle effect has three elements: a muzzle cone, a flashlight and sparks.

First, you’ll create a muzzle cone to simulate a spray of energy when a projectile fires.

Making the Base Muzzle Cone

Open DemoScene from RW/Scenes. In RW/Prefabs/VFX under the Asset folder, there’s a prefab called StarterParticle, which contains the following:

  • A reference object at the origin that helps align particle objects inside an effect.
  • A dummy particle system. This doesn’t render anything, but it helps play or stop all the child particle systems at the same time.

Duplicate StarterParticle by pressing Command/Control-D, then rename the new object to Muzzle. Drag Muzzle from the Project panel into the Hierarchy and position it near the Shooter character.

Positioning the Muzzle near the Shooter character

Right-click to call up the Create menu. Select Effects ▸ Particle System to create a new particle effect and name it MuzzleCone. Select it in Hierarchy and click the Restart button in Scene to preview the particle.

Next, you’ll turn MuzzleCone into a one-shot particle. This is a trick to make the particle system behave like a simple animation. To do this, adjust the following settings:

  • Main: Set Start Speed to 0 and Looping to false.
  • Emission: Set Rate Over Time to 0 and Burst Count to 1.
  • Shape: Disable this option.

Menus containing the settings for the MuzzleCone

Next, you’ll define the shape of the particle using the Renderer module.

Defining the Particle’s Shape

Traditionally, a particle would make use of an image to define the shape. For this example, you’ll make use of a mesh instead.

Apply the following settings to the Renderer to turn the particle from a single image into a mesh.

  • Render Mode: Mesh
  • Mesh: Mesh_Cone
  • Material: Mat_Muzzle
  • Render Alignment: Local

The Render Alignment setting makes the mesh align with its origin instead of always facing the camera.

Selecting the correct settings for the Renderer

Uh oh, nothing appears. That’s because the mesh is too small to see right now. To correct this, you need to change the particles’ start size. Go to Main and change Main Start Size to 50.

Then, adjust the particles’ direction and position by setting Rotation to 180 and Z to 0.5.

Muzzle cone starting to look like a cone

All right, that looks better! Now that the shape and size are correct, you’ll move on to the color.

Changing the MuzzleCone’s Color and Timing

Select MuzzleCone again and update Color Over Lifetime. Expand it, then select Color to open the Gradient Editor. Choose the fire-tone color from one of the presets.

Fire Gradient

The last step is to adjust the timing. To make MuzzleCone disappear right after it appears, change Start Life Time in Main to 0.2.

Testing the Muzzle Effect

So everything looks good, but does it work? To find out, you’ll test the Muzzle prefab using the Shooter Character.

First, hide the reference object by disabling ReferenceSphere in Muzzle. Then, select the Prefab menu from the top-right menu in Inspector and click Apply.

Next, select the Shooter in the Scene and drag Muzzle in Prefab/VFX to Muzzle Prefab.

Click Play to test the effect.

Applying muzzle prefab

You should now see a cone shaped muzzle effect appear in front of the weapon each time the weapon is fired.

The basic settings for Muzzle are ready. However, adding a flash and some sparks will make it look even better. You’ll do that next.

Making the Muzzle Flash

Your next goal is to create a flash effect consisting of a sudden light that appears with the muzzle cone. It’s composed of a big circle and a point-light object.

Select Muzzle in Hierarchy. Next, right-click and select Effects ▸ Particle System. Name the newly created particle object Flash.

Now, you need to change some settings to make the particle a one-shot particle. In Main, set Start Speed to 0 and Looping to false.

Next, in Emission, change Rate Over Time to 0 and Burst Count to 1

Finally, disable Shape.

Since the default particle material is already a circle, you don’t need to do anything to define the shape.

Next, adjust the size, timing and color by going to Main and changing the following settings:

  • Start Size: 3
  • Start LifeTime: 0.1
  • Start Color: FFF247

Finally, you’ll add a light to the effect by right-clicking Flash and selecting Light ▸ Point Light. Disable the light object. Next, select Flash, check and open the Light. Finally, drag the light object to the light property and set the Ratio to 1.

Click Restart in Scene to preview.
Adding point light

Now, a bright flash of light appears for a second everytime the weapon is fired.

Making the Muzzle Sparks

Your last step is to add some sparks to the Muzzle to make it look super realistic.

Select Muzzle in Hierarchy. Right-click, then select Effects ▸ Particle System to create a particle object. Rename the new Particle System Sparks.

Next, you want to modify the size and timing of the particle object. Go to Main and select the following settings:

  • Start Size: 0.05 – 0.1.
  • Start Life Time: 0.1 – 0.4.
  • Start Speed: 3- 5.
  • Looping: false.

Next, under Emission, select:

  • Rate over Time: 0.
  • Bursts/Count: 15.

Rename particle system

Finally, you’ll modify the particle’s shape and color. Under Shape, change the Radius to 0.1. Under Color over Lifetime, set the color to a white/yellow fade-out gradient.

white yellow gradient

The muzzle effect is ready! Apply the changes to the prefab, remove the working VFX from Scene and click Play to preview.

Apply Muzzle Effect

You should now see the cone shaped muzzle blast, a flash of light along with tiny debris flying outward.

Making the Impact Effects

Your next goal is to use an effect, a simple glowing light, to show where the projectile hits. To do this, you’ll select an impact effect that spawns when a projectile collides with another object.

First, create the parent impact effect with the following instructions:

  • Duplicate StarterParticle in Prefab/VFX and rename it Impact.
  • Drag Impact to Hierarchy.
  • Move the impact particle near the Target by changing its position to X:2.5, Y:2, Z:11.85

Here’s the setup:
Impact effect setup

Let’s continue by adding an Impact Glow.

Adding an Impact Glow

When the projectile hits the target, a tiny explosion should go off. This effect is achieved by making the impact point glow.

Next, you want to add a Glow to the effect.

Create a new particle system under Impact in Hierarchy, and rename the new object Glow.

Make the Glow object a one-shot with the following settings:

  • Main: Set the Start Speed to 0 and the Looping to false.
  • Emission: Select 0 for the Rate Over Time and 1 for the Burst Count
  • Shape: Select Disable.

Adjust the size, timing and color by going to Main and selecting these settings:

  • Start Size: 3.
  • Start Life Time: 0.1.
  • Start Color: FFE68D.

Do another play test, and if the impact glow effect looks OK, hide or remove the Reference object — you no longer need it.

Menu settings to hide or remove the reference object

You should now see the impact glow effect, but there’s some kind of clipping happening. Let’s fix that.