Question by
cbjunior · Feb 09, 2016 at 03:03 PM ·
c#scripting problemparticle systemgunfire
Particle System for gun fire effect won't replay after first fire
Hey guys, I'm currently designing a top-down shooter and I have a particle system that I'm using for the gun being fired that simply creates a burst of orangish-red particles at the beginning of the system. For some reason, the first time my character fires I get the effect, but every subsequent time the effect doesn't play.
Here is my code:
void FixedUpdate()
{
//Movement code
bool firing = Input.GetMouseButtonDown(0);
if (firing && !isSprinting)
{
if (!fireEffect.isPlaying)
{
fireEffect.Play();
}
anim.SetBool("Firing", true);
}
else
{
if (fireEffect.time >= fireEffect.startLifetime && fireEffect.isPlaying)
{
fireEffect.Stop();
fireEffect.Clear();
fireEffect.time = 0.0f;
}
anim.SetBool("Firing", false);
}
}
and here are the settings of the Particle System in the inspector:
I have tried tweaking the settings using different combinations of setting the playback time and using Stop() and Pause(), but I just can't seem to get it to work. What am I doing wrong?
problem.jpg
(45.5 kB)
Comment