Particle System - Fireworks

foreword

This is the last homework of this semester. In this paper, the fireworks effect is realized through the particle system

camera background

Set the camera background to black for easy display of fireworks effect
insert image description here

fireworks making

The particle system is mainly divided into two parts. The main part drives the fireworks into the air, and the other part is the exploding fireworks. Then both parts bring the surrounding particles
insert image description here
Sub as the accompanying particle system. Make a copy and copy it to Burst.

Fireworks production

Basic Settings

insert image description here
The firework rises very fast, the life cycle is set to 1.2, the speed is set to 55
and the color is set to red and yellow

Emission

insert image description here
firework every time

Shape

insert image description here
The launch shape is conical, and the angle can be adjusted to a smaller point to shoot higher

Velocity over Lifetime

insert image description here
Set the particle speed from 1 to 0 to simulate the slowing down of fireworks speed

Sub Emitters

insert image description here

Trails

insert image description here

Renderer

Make snowflake pictures first, then use them to make materials, and add materials in renderer
insert image description here

Companion Particle System Production

Basic Settings

insert image description here

Emission&Shape

insert image description here

Size over Lifetime

insert image description here

Rotation over Lifetime&Renderer

insert image description here

Made by Burst

Basic Settings

insert image description here

Emission&Shape

insert image description here

Size over Lifetime&Sub Emitters&Trails

insert image description here

Renderer

consistent with other particles

control

Control fireworks start stop, change color

public class Fireworks : MonoBehaviour
{
    
    
    // Start is called before the first frame update
    public ParticleSystem[] fireworks;
    int cnt=0;
    int l;
    
    void Start()
    {
    
    
        GameObject[] tmp;
        tmp = GameObject.FindGameObjectsWithTag("Fireworks");
        l=tmp.Length;
        fireworks = new ParticleSystem[l];
        
        
        for(int i = 0; i < l; ++i)
        {
    
    
            fireworks[i] = tmp[i].GetComponent<ParticleSystem>();
            fireworks[i].Stop();
        }
        

       
    }
    
    
    private void OnGUI() {
    
    
        if (GUI.Button(new Rect(Screen.width/2-150, Screen.height-100, 80, 50), "Start")) fireworks[cnt].Play();
        if (GUI.Button(new Rect(Screen.width/2-50, Screen.height-100, 80, 50), "Pause")) fireworks[cnt].Stop();
        if (GUI.Button(new Rect(Screen.width/2+50, Screen.height-100, 80, 50), "Change")){
    
    
            fireworks[cnt].Stop();
            cnt++;
            cnt%=l;
            fireworks[cnt].Play();
        }
    }
}

Show results

insert image description here

demo video

reference blog

Unity makes particle fireworks

Guess you like

Origin blog.csdn.net/lydsera/article/details/128523870