Implementing Confetti Coming out of an object In Unity

blog

Keval Padia

A Particle system is a component of Unity that is used to add some extra effects in your game like fire, flowing water, smoke etc. which is not possible through the normal game object having meshes and textures. A particle system generally emits particles in random positions within a predefined space.

Particles are small, simple images or meshes that are displayed and moved in great numbers by a particle system.

In this unity confetti particle effect addition tutorial, we will implement a particle system that will look like confetti.

Prerequisites:

  1. Unity 5 or higher.
  2. How to add a new Particle System?
  3. Manipulating Particle System

How to add a new Particle System?

To add a new unity confetti particle system click on Game-Object in Menu and then select Particle System. As it is a component you can also add it to an empty game object from Component ->Effects -> Particle System. Now select particle system from scene hierarchy. You can see a Particle Effect dialogue in the scene view which allows you to Simulate and Stop the particle system. Set the camera’s clear flag to Solid colour and set colour black. Also, set the projection to Orthographic so we can see the effect of the particle clearly. Also set camera position to (0,1,0).

Manipulating Particle System

To create a confetti-like particle system we need to manipulate the default particle system. Create a new particle system and name it “Confetti”. Set its position to (0,-1.87,5)and rotation to (-90,0,0). The default particle system has several sub-sections as shown in the inspector.0

First of all, create a material and name it ConfettiMat and set its shader to Particles ->Anim Alpha Blended. Set it in the Renderer section of the particles system in the inspector. This applies a material to a particles system and renders it in-camera.

Now set the following values :

1. Duration:

It is The length of time in seconds for the particle to run. Set this value to 0.1.

2. Looping:

if true, the emission cycle will repeat after the duration.Set it true.

3. Start Delay:

The delay in seconds before the particle system start emitting. Set this value to 0.

4. Start Lifetime:

The initial lifetime in seconds for the particles. The particle is destroyed after this elapsed time. Set this value to 8.

5. Start Speed:

The initial speed of the particles. The greater the speed of the particles, the more spread out they will be. Set this value to 20.

6. Start Size:

the initial size of the particles. Set this value to 0.25.

7. Start Rotation:

The initial rotation angle of the particles. Set this value to 0.

8. Start Color:

The initial colour of the particles. Set the type of value to the gradient. Click on the colour part, it will open a Gradient Editor window. Set the colour values as shown in the image. You can also set it as you want.

9. Gravity Modifier:

Scales the gravity value set in Unity’s Physics Manager window. If it’s set to 0, the gravity will be turned off. Set this value to 3.

10. Play On Awake:

Starts emitting immediately when enabled. If this is turned off, you have to manually start the particle system via script or an animation system. Leave this setting on.

11. Max Particles:

The maximum amount of particles the particle system is allowed to have alive at any time. Set this value to 300.

12. Emission:

The Emission module is one of the most important modules in Unity particle systems; it handles the number and timing of emitted particles in the system to create a continuous flow or a sudden burst of particles depending on your needs.

13. Rate over time:

It is the number of particles emitted per second (Time), or alternatively, per unit (Distance) 300

14. Shape:

The Shape module, as the name implies, controls the shape and the behaviour of particles in that shape. Set its value as follows:

15. Force over Lifetime:

Controls the force of each particle during its lifetime. Set its value as shown in the picture:

16. Rotation over a lifetime:

Controls the angular velocity of each particle during its lifetime. Set the value as shown below:

17. Collision:

This allows you to specify multiple collision planes that the particles can collide with. Create an empty gameobject and name it Surface. Set its position to (0,-4.1,5) and add the BoxCollider component to it. This will allow the particles to collide with the surface and create a real-time confetti-like physics effect.

You can create as many planes as you want for particle collision. You can also rotate that plane using rotation tools in

particle system -> collision -> scale plane

Click on the simulate button, and you can see colourful particles like confetti. Now create a Cylinder game object and set its position to (0,-2.81,4) and scale to (1,1.2,1).

Now hit the play button, and you can see confetti particles coming out from the cylinder.

Related Post

Unity 5
26 Aug 2021320 Views

How to Implement Slingshot In Unity - A Step by Step Guide

A slingshot is normally a small hand-powered projectile  weapon . The classic form consists of a Y-shaped frame held in the off hand, with...

AssetBundles in Unity3D
19 Dec 2017177 Views

How To Implement AssetBundles in Unity3D

In this blog post, We try to explain How to Get data from AssetBundle on The Server and Data From AssetBundle In Local. What Is An...

Animation Clip in Unity3D
04 Dec 2017159 Views

How to Create Animation Clip in Unity3D

Animation Clips are one of the core elements of Unity’s animation system. Gameobjects in Unity can be animated using animation Clip. Using...