- Home /
This question was
closed Mar 29 at 05:43 PM by
ninedivinez for the following reason:
The question is answered, right answer was accepted
Question by
ninedivinez · Mar 29 at 05:36 PM ·
particlescolorparticle systemalpha
Trying to change the alpha on a particle system.
I've tried many ways to try and adjust the color for a particle system. Nothing I do changes the color. I've tried to change the starting color, but I realized that I have to restart the partical system to make that update, which I do not want. So I tried changing the color over lifetime, but that has no results either. The code I've got currently is:
float alpha;
float maxDistFromPlayer = 100f;
float numerator = Mathf.Clamp(distance, 0, maxDistFromPlayer);
float denominator = maxDistFromPlayer;
float percent = Mathf.Clamp((numerator / denominator), 0, 1);
alpha = 255 * percent;
particleColor = new Color(startingColor.r, startingColor.g, startingColor.b, alpha);
colorModule.color = new ParticleSystem.MinMaxGradient(particleColor, particleColor);
Comment
Answer by ninedivinez · Mar 29 at 05:42 PM
Turns out, alpha is anywhere from 0 to 1. So once I removed multiplying the percent by 255, that fixed the issue.