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
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
Sub as the accompanying particle system. Make a copy and copy it to Burst.
Fireworks production
Basic Settings
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
firework every time
Shape
The launch shape is conical, and the angle can be adjusted to a smaller point to shoot higher
Velocity over Lifetime
Set the particle speed from 1 to 0 to simulate the slowing down of fireworks speed
Sub Emitters
Trails
Renderer
Make snowflake pictures first, then use them to make materials, and add materials in renderer
Companion Particle System Production
Basic Settings
Emission&Shape
Size over Lifetime
Rotation over Lifetime&Renderer
Made by Burst
Basic Settings
Emission&Shape
Size over Lifetime&Sub Emitters&Trails
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();
}
}
}