- Home /
This question was
closed Nov 26, 2020 at 04:39 PM by
stephen_gregory for the following reason:
The question is answered, right answer was accepted
Question by
stephen_gregory · Nov 08, 2020 at 04:42 PM ·
particlescoroutine
How to add particle effects at the end of the game?
Hello
I try to add some particle effects when the player reaches a certain score, I created a routine for this but I don't know where to call it because I would have to call it in the update but it can't Does anyone know how I can solve this problem?
Comment
Best Answer
Answer by rh_galaxy · Nov 08, 2020 at 05:50 PM
Create the particle system in the editor, then create a public variable in the class that counts the score. Then drag the particle system to that variable in the inspector, and in the code you do Play when the score is reached.
public ParticleSystem effect; //<- drag particle system here in Inspector
bool effectStarted = false;
Update()
{
if(score > valueToWin && !effectStarted)
{
effectStarted = true;
effect.Play();
}
}