Particle Systems | Unity Tutorial

Do want to make a game that has explosions, smoke, or flames? To add effects like these in Unity, you can create particle systems. If you are a beginner and want to learn how to build virtual reality games, check out our Unity 3D course

Each particle in a particle system is a simple mesh. The effect of all the combined particles creates a moving object.

To create a particle system, right-click in the Hierarchy, and select “Particle System”. “Particle System” will appear in the Hierarchy. In the Scene, Particle System is represented as a trio of arrows with white clouds emerging from its center.

Select Particle System. In the Inspector, change its position to 0 0 0. In the Scene, you will see white clouds floating up from the position 0 0 0.

Moving a Particle System

You can move Particle System like any other object. To have the particle system be part of Cube, drag “Particle System” onto “Cube” in the Hierarchy.

Particle System’s position in the Scene does not change. However, its Y Position value in the Inspector changes to “1.5”. This occurs because the particle system’s position is now local. It is relative to the parent, Cube.

Cube is in the position 0 -1.5 0. Particle System is in the position 0 1.5 0. To position the particle system in the center of the cube, change Particle System’s Y Position value to 0.

Notice that there is a Particle Effect window in the Scene. With this window, you can pause, stop, and restart the particles’ movement.

Properties of a Particle System

In the Inspector, Start Delay refers to how long after the game’s beginning the particles will begin appearing. Start Lifetime refers to how long the particles will appear on the screen before disappearing. Set Start Lifetime to 1.

The higher the Start Speed, the faster the particles will move. Set Start Speed to 3. Change Start Color to yellow.

To demonstrate the Gravity Modifier, let’s rotate the particle system. Select the Rotating tool. Drag the green circle until Particle System’s Rotation values are approximately -30, -90, and -90.

Change the value of the Gravity Modifier to 1. You can increase the speed to 6. In the Scene, the particles will appear to be jumping out of the cube and falling to the floor.

Move Particle System around the Scene. No matter how quickly you move the game object around the screen, all the particles will move will your cursor.

However, if you change Simulation Space to “World” and move the game object, not all the particles will follow the object. The particles that have already fallen out of the object will continue falling in their trajectory.

In the Emission component, you can change the rate of particles that appear from the game object. Set Rate to 8. In the Shape component, you can form the shape that contains the particles. For instance, in the following screenshot, the particles are contained in a cone that has an angle of 6.1.

To learn more about particle systems, check out our Unity 3D course, where you build 30 virtual reality games!

Applying Physics to an Object | Unity Tutorial

For your VR game to feel real, its objects should move like they would in real life. In this tutorial, you will learn how to make your game objects respect the laws of physics. If you are a beginner and want to learn how to build virtual reality games, check out our Unity 3D course

Create a cube in the Hierarchy. We will apply physics to Cube so that it respects gravity. Move Cube up to a Y position of about 4.

By default, Cube does NOT respect gravity. Cube will remain suspended in the air – it won’t fall.

To prove it, press the Play button above the Scene window. The editor will darken. The Game window will open. The Play, Pause, and Forward buttons will become blue, meaning that the scene is live. The particles will jump and fall from Cube, but Cube will remain stationary.

Cube will not fall because we need to specifically tell Unity that we want Cube to respect the laws of physics. Press the Play button again to stop playing the game. In the Hierarchy, select Cube. We will give Cube a new component in the Inspector.

The Rigidbody Component

Click on the “Add Component” button at the bottom of the Inspector. Type “rigidbody” in the search bar. Select “Rigidbody”.

A Rigidbody component will appear in the Inspector. Rigidbody contains properties that pertain to physics. By creating this component for Cube, we have made Cube respect the laws of physics. Press the Play button. Cube will fall to the floor.

Currently, the particles fall to the left. Let’s have them fall from the bottom of the cube instead. Stop playing the scene. Select Particle System in the Hierarchy. In the Inspector, change the X Rotation value to 90. Press Play. The cube will fall, and particles will tumble out of it.

Stop playing the scene. Change the cube’s Rotation values to 45 45 40. Press Play to see the cube fall at an angle. When the cube hits the floor, it will rotate to sit on the floor.

Let’s make the cube collide with another object, such as a sphere. Stop playing the scene. In the Hierarchy, create a sphere. Position Sphere above the floor and under the cube, as in the following image. The sphere’s Position values should be about 0.2 5 0.14.

Press Play to see Cube fall and bounce against Sphere, as in the following image.

Stop playing the scene. Create two more spheres. Position them under Cube, as in the following image. To duplicate a sphere, press Control/Command+D. Alternatively, right-click, and select “Duplicate” in the Hierarchy.

Press Play to see Cube fall and tumble against the spheres.

Saving Your Project

In the Hierarchy, the file named “Untitled” contains the game’s elements. As evident in the following image, there is an asterisk beside “Untitled”. This means the file is not saved.

To save the scene, go to File > Save Scene. Give the file a name such as “Game.unity”. “Untitled” will change to “Game”. A file named “Game” will appear in the Assets folder.

To learn more about Unity, check out our Unity 3D course, where you build 30 virtual reality games!