[Solved] Particles work only on the first time... Yes I have checked related posts... nothing works thou
I know there are other posts about this & I think I've tried them all ..... nothing works thou I just upgraded my Unity --- Unity 2018.3.5f1..... and I still have the same problem
public class ParticleController_Player1 : MonoBehaviour
{
public ParticleSystem Score_Blue_Small;
private ParticleSystem.EmissionModule Score_Blue_Small_Emission;
//
void Awake()
{ Score_Blue_Small_Emission = Score_Blue_Small.emission; }
//
void Start()
{ Score_Blue_Small_Emission.enabled = false;
// Score_Blue_Small.Play(); }
//
void Update()
{
if (Static_Class_Variables.Score_1Player_ParticleTrigger == true
{ RunParticale_1(); }
}
//
void RunParticale_1()
{
Score_Blue_Small.Play();
Score_Blue_Small_Emission.enabled = true;
//
// ParticleSystem Score_Blue_Small;
// Score_Blue_Small.startLifetime = Score_Blue_Small.startLifetime;
//
StartCoroutine(A_letPlay_IEnum());
//
// All the other stuff I have tried that didn't make any differance
// // Score_Blue_Small_Emission.enabled = false;
// // Score_Blue_Small.Clear();
// // Score_Blue_Small.time = 0;
// // Score_Blue_Small.Simulate(0.0f, true, true);
// // Score_Blue_Small.startLifetime = Score_Blue_Small.startLifetime;
// // Score_Blue_Small.emissionRate = 10;
// // Score_Blue_Small.enableEmission = true;
// // Score_Blue_Small.enable = true;
// // ParticleSystem.EmissionModule module_P1a = Score_Blue_Small.emission;
// // module_P1a.enabled = true;
}
//
IEnumerator A_letPlay_IEnum()
{
yield return new WaitForSeconds(4f);
//
Score_Blue_Small.Stop();
//
Score_Blue_Small_Emission.enabled = false;
}
//
}
Anything else that I could try.... or any references that point to anything I haven't tried yet would be very much appreciated..... Thanks for any responses
There seems to be a trick that works for some people ..... some of the time..... lots of tricks floating around.... but I still have yet to find a trick that will (properly) work for me........ I can turn the particles on and off by enabling/disabling a parent empty gameobject.... But this looks really bad.... it just makes all the particles suddenly and abruptly disappear ( does not look good at all )
I also tried setting the particles to world space instead of local space.... but this did nothing for me either
My problem was solved...... There is a 'Stop Action' in the 'Inspector' gui ....... I had to set it to 'Callback' for my particles to repeat.......... I find it strange that absolutely nothing I have read about particles during my long struggle to get this working... even mentioned this..... maybe it just seems like such an obvious thing to someone that has done this before.... but it sure was not obvious to me... lol
Answer by ifurkend · Feb 16, 2019 at 05:01 PM
Don’t call Play() on Update because you’re resetting your effect on every single frame. With the effect being switched via Emission module, you only need to call Play() on Awake/Start/Enabled, thus it is unnecessary to call Stop() either when you are disabling the Emission module in the same time.
Firstly... Thanks for your response I did try this already...... it does not work for me..... I tried both in Start and Awake.... I also tried before and after the 'Particle.enabled = false;' line.... and yes...... I didn't use play again ... only the 'Particle.enabled = false; /or/ Particle.enabled = true;' afterward ........... Nothing happens at all.... no particle plays ever.... not even the one time.... this is that I tried this time.....
public class ParticleController_Player1 : $$anonymous$$onoBehaviour
{
public ParticleSystem Score_Blue_Small;
private ParticleSystem.Emission$$anonymous$$odule Score_Blue_Small_Emission;
//
void Awake()
{
Score_Blue_Small_Emission = Score_Blue_Small.emission;
//Score_Blue_Small.Play();
}
//
void Start()
{
Score_Blue_Small_Emission.enabled = false;
Score_Blue_Small.Play();
// Score_Blue_Small_Emission.enabled = false;
}
//
void Update()
{
if (Static_Class_Variables.Score_1Player_ParticleTrigger == true)
{
RunParticale_1();
}
}
//
void RunParticale_1()
{
//Score_Blue_Small.Play();
Score_Blue_Small_Emission.enabled = true;
//
StartCoroutine(A_letPlay_IEnum());
}
//
IEnumerator A_letPlay_IEnum()
{
yield return new WaitForSeconds(4f);
//
//Score_Blue_Small.Stop();
//
Score_Blue_Small_Emission.enabled = false;
}
//
}
Any other suggestions? ........... I'm all out of ideas/suggestions to try
I do not entirely understand your circumstances. If Score_1Player_ParticleTrigger remains true after the effect is done playing, the effect will repeat itself until the var becomes false, but ParticleSystem.isPlaying is the easiest answer for you, even though I personally would avoid it at all cost:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ParticleController_Player1 : $$anonymous$$onoBehaviour
{
public ParticleSystem Score_Blue_Small;
void Update()
{
if (Static_Class_Variables.Score_1Player_ParticleTrigger == true && Score_Blue_Small.isPlaying == false)
{
Score_Blue_Small.Play();
StartCoroutine("A_letPlay_IEnum");
}
}
IEnumerator A_letPlay_IEnum()
{
yield return new WaitForSeconds(4f);
Score_Blue_Small.Stop();
}
}
I wanted to say thank you for your response...... I did try your suggestion early on... but abandoned it because it didn't work.... I have tried so many things since then..... because of your response I revisited doing it that way again..... and because of that, I did find the answer.... It was the setting in the 'Inspector' gui..... in the particle system there is a setting named 'Stop Action' ...... once I set this to 'Callback' everything worked like a charm ^_^............ I really want to say thanks again for your response..... because I don't think I would have revisited doing it that way again.... or ever found the answer...... cheers
Your answer
Follow this Question
Related Questions
Checking total number of particles in a scene 1 Answer
Emitting water 0 Answers
Tanks Tutorial - dust trails not emitted on MovePosition 4 Answers
Low particle emission rate 1 Answer
Can't find a way to add particle effects to a collision 2 Answers