- Home /
Question by
Spinnetje11 · Apr 01, 2018 at 08:10 PM ·
c#particlesystemscore system
How can I use particles of several partical systems for a score?
Hello,
At the moment I'm working on a game with the goal to destroy objects. When an object is destroyed a particle system is a particlesystem is initiated. I then add up the amount of particles and that should be the score. This is de code I use:
void VindVlekken()
{
float score = 0;
vlekken = GameObject.FindGameObjectsWithTag("splash"); //Vult een array met objecten met de tag splash
for (int i = 0; i < vlekken.Length; i++)
{
ParticleSystem splash = vlekken[i].GetComponent<ParticleSystem>();
int aantalSplash = splash.particleCount; //De particles onstaan pas een paar frames na de start dus de eerste partcleCounts geven 0
score += aantalSplash;
//ParticleSystem splash = vlekken[i].GetComponent<ParticleSystem>();
//ParticleSystem.Particle[] spetters = new ParticleSystem.Particle[splash.maxParticles];
//int aantalSplash = spetters.Length;
//score += aantalSplash;
}
Debug.Log(score);
}
The problem is that when particles disapear (are killed) the amount of particles doesn't change. This method is called in the update() so I would expect the amount to be updated.... Is there a way to really count the particles in a scene?
I must say that I'm really new to programming and such, so I apologize if I'm slow of understanding
Comment