- Home /
Particles do not appear on play but do on emit
I am trying to spawn a directional from the simple particle pack. When I call Emit directly, something seems to happen. I searched through some questions and did things like set enableEmissions to true. I have their SimpleFlame Prefabs attached to my public instance variables. I know that the loop in play gets executed, but nothing seems to happen at all. The game objects for the particles exist. I think I have broken something in rearchitecting their example.
I abstracted their logic into a script like this:
using UnityEngine;
using System.Collections.Generic;
public class Spawner: MonoBehaviour
{
public GameObject Flare0;
public GameObject Flare1;
private List<Flare> flares;
private float elapsed;
private double delay;
private class Flare
{
private GameObject particleObject;
private ParticleSystem[] particleSystems;
public Flare(GameObject flare)
{
this.particleObject = Instantiate(flare, Vector3.zero, Quaternion.identity) as GameObject;
this.particleSystems = this.particleObject.GetComponentsInChildren<ParticleSystem>();
this.particleObject.SetActive(false);
}
public void Play()
{
this.particleObject.SetActive(true);
foreach (ParticleSystem ps in this.particleSystems)
{
ps.Clear();
ps.Play();
}
}
}
void Start ()
{
this.elapsed = 0;
this.delay = 5;
this.flares = new List<Flare>(2);
this.flares.Add(new Flare(this.Flare0));
this.flares.Add(new Flare(this.Flare1));
}
void Update ()
{
this.elapsed += Time.deltaTime;
if (this.elapsed >= this.delay)
{
flare.Play();
this.elapsed = 0;
}
}
}
I have narrowed the problem to the Directional effects not working. The flares and explosions work fine. The directionals work in the test scene. Why won't they work in mine? They don't even simulate correctly in either scene. wtf.
$$anonymous$$ake sure playOnAwake is set to true, this way the particles will begin emitting on Awake() plus any delay you have set
Your answer
Follow this Question
Related Questions
Manually and efficiently placing thousands of particles 0 Answers
ParticleSystem.Play() does not play particle. 10 Answers
ScriptableObject.ParticleSystem.Play() Doesn't Work. 1 Answer
Particle system won't restart emitting before last particle has died 3 Answers
Emit particles from image/sprite 1 Answer