Hey,
I want to play a Particle System every time I shoot, but I don’t know how to play a Particle System multiple times without having to reset it.
Hey,
So I’ll show you two different ways of playing particles for guns.
Machine Gun/Laser:
Turn the emission of the particle system on/off:
ParticleSystem particles;
void Start()
{
particles = GetComponent<ParticleSystem>();
}
void Update()
{
var emission = particles.emission;
if (Input.GetKey(KeyCode.Space))
{
emission.enabled = true;
}
else
{
emission.enabled = false;
}
}
Regular Gun:
Instantiate new particles every time you shoot:
[SerializeField] GameObject particles;
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Instantiate(particles, transform.position, Quaternion.identity);
}
}
1 Like
ParticleSystems (particlesystems): emitting in various positions in space (no play / stop):
1 Like