- Home /
Change startcolor of particle system through script
I have 2 scripts, in one of which I have 2 color variables:
public Color color;
public Color sparkColor;
In the other script, I have a function where I want to change the startcolor of a particle system to the given colors:
void ChangeColor()
{
particleSystem.GetComponent<ParticleSystem>().startcolor = otherScript.color;
particleSystem2.GetComponent<ParticleSystem>().startcolor = otherScript.sparkColor;
}
The problem is, when I do this the particle system shuts off. I tried changing the function to one of the preset colors (startcolor = Color.red) and this worked. But how do I make it so I can change it to a color I choose?
Weird
How do you define the colors in the other script?
I'm as lost as you, i guess.
Have you tried forcing it to play from your script after you set the values. $$anonymous$$aybe, stopping it first. That's what I would try.
The alpha was set so the color was transparent. No idea why, but I just adjusted the alpha, and it was fixed :D
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Smooth Camera Background Color Changing? 1 Answer
How do I change Particle System color via script in Unity 5.6.1f1? 1 Answer
SpriteRender.color not changing the color 1 Answer
Distribute terrain in zones 3 Answers