Why does my particle system get enabled with a delay?

Good day all,

I have candle in my game in which the player will light up by pressing a key. The flame of my candle is made up of a particle system, so I thought I’d achieve this by disabling and enabling the emission of the particle system from my script.


It (almost) works, but there’s one problem: it gets enabled with around an 8 second delay.


I’m not sure what’s happening, since I have delay time as 0.


Here’s the code:

private void Update()
{
    if (Input.GetKeyDown(KeyCode.L))
    {
        LightUpCandle();
    }
}
void LightUpCandle()
{
  if (Physics.Raycast(MainCamera.transform.position, MainCamera.transform.forward, out hit, distance))
  {
      if (hit.collider.CompareTag("Candle"))
      {
          ParticleSystem.EmissionModule em = candleLight.emission;
          em.enabled = true;
      }
   }
}

And here’s what my particle system and its emission looks like:


177143-capture1.jpg


Can somebody tell me what’s the issue?

The duration is set to 8 seconds and that is roughly the delay. Try to set the time to 0 when you enable it to restart from the beginning. I forget the API but that’s where I would start.

you should call particle play method to restart the loop cycle which is the 8 second duration just like joemane22 said. since you have play on awake enabled in main module your particle system is playing but not emitting so when player gives input it will emit when 1 loop cycle has passed which depending on the input time is between 0 to 8 seconds of particle duration