- Home /
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:
Can somebody tell me what's the issue?
Answer by joemane22 · Mar 07, 2021 at 11:56 PM
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.
I looked at the documentation and I would use the Stop Pause and Play methods rather than enabled.
Answer by DL_se · Mar 08, 2021 at 10:46 PM
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
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Destroy particles based on bounds not lifetime 0 Answers
How to Destroy A single Particle 1 Answer
how can I get particle.position out of shuriken system? 2 Answers