Hey,
I’m using Unity3ds built in particle system to simulate clouds. To do so I spawn all particles at the beginning of the scene and they exist for the complete level time (which works because my levels have a maximum time of appr. 3 mins). As my game is kind of a strategy game with a camera floating (high) above the ground sometimes the clouds obscure the actual level.
What I want to do is fade the clouds out close to invisibility. I tried to do so using the following code:
ParticleSystem pS = Clouds[i].GetComponent<ParticleSystem>();
ParticleSystem.Particle[] pSparticles = new ParticleSystem.Particle[pS.particleCount];
pS.GetParticles(pSparticles);
if(pSparticles.Length > 0)
{
for(int a = 0; a < pSparticles.Length; a++)
{
if(pSparticles[a].color.a > 30f)
{
Color returnColor = new Color(pSparticles[a].color.r, pSparticles[a].color.g, pSparticles[a].color.b, pSparticles[a].color.a - 2);
pSparticles[a].color = returnColor;
}
}
pS.SetParticles(pSparticles, pSparticles.Length);
}
To a certain extend this works. I query the particles, i get the color and change it, apply it back but for some reason the applied color changes to rgba(255,255,255,255), although none of the applied values is 255 (initially).
I’ve got no idea from where this behaviour comes. Any ideas?
Thanks!