- Home /
Particle system not outputting what it's supposed to.
So I'm making a game for little children whare you draw a line for a plane to follow and you need to fly through different color clouds that change the color of your trail.
I have six different colors and five of them work correctly without any issues, but the orange one does not.
Here is clearly correct behavior, after the player hits red cloud, particle system color is red and thus the line is also red.
Here is the wrong behavior after you hit the orange cloud. You can see particle system kind of knows it's supposed to output orange color but it doesn't.
Code for all of these clouds is the same and they all have similar hitboxes and other parameters. Theres also a bool value for each cloud so I know for sure the plane hits the orange cloud and toggles it.
Code for this is here. (punainen, keltainen, oranssi, vihreä, liila and sininen are colors in finnish)
public void OnTriggerEnter(Collider other)
{
if (other.tag == "pilvi")
{
Debug.Log(other.name);
/*
ParticleSystem ps = GetComponent<ParticleSystem>();
ParticleSystem pss = GetComponent<ParticleSystem>();
var main = ps.main;
var mainn = pss.main;
*/
Color oranssi = new Color(255, 51, 0, 255);
Color liila = new Color(204, 0, 255, 255);
Color keltainen = new Color(255, 255, 0, 255);
Color punainen = new Color(255, 0, 0, 255);
Color turkoosi = new Color(0, 255, 255, 255);
Color vihreä = new Color(0, 255, 0, 255);
ParticleSystem.MainModule savu = ps.GetComponent<ParticleSystem>().main;
ParticleSystem.MainModule savu2 = pss.GetComponent<ParticleSystem>().main;
if (other.name == "pilvi_oranssi")
{
pilvi_oranssi_toggle = true;
savu.startColor = new ParticleSystem.MinMaxGradient(oranssi, new Color(255, 102, 0, 0));
savu2.startColor = new ParticleSystem.MinMaxGradient(oranssi, new Color(255, 102, 0, 0));
}
if (other.name == "pilvi_keltainen")
{
pilvi_keltainen_toggle = true;
savu.startColor = new ParticleSystem.MinMaxGradient (keltainen, new Color(255, 255, 0, 0));
savu2.startColor = new ParticleSystem.MinMaxGradient(keltainen, new Color(255, 255, 0, 0));
}
if (other.name == "pilvi_punainen")
{
pilvi_punainen_toggle = true;
savu.startColor = new ParticleSystem.MinMaxGradient(punainen, new Color(255, 0, 0, 0));
savu2.startColor = new ParticleSystem.MinMaxGradient(punainen, new Color(255, 0, 0, 0));
}
if (other.name == "pilvi_turkoosi")
{
pilvi_turkoosi_toggle = true;
savu.startColor = new ParticleSystem.MinMaxGradient(turkoosi, new Color(0, 255, 255, 0));
savu2.startColor = new ParticleSystem.MinMaxGradient(turkoosi, new Color(0, 255, 255, 0));
}
if (other.name == "pilvi_vihreä")
{
pilvi_vihreä_toggle = true;
savu.startColor = new ParticleSystem.MinMaxGradient(vihreä, new Color(0, 255, 0, 0));
savu2.startColor = new ParticleSystem.MinMaxGradient(vihreä, new Color(0, 255, 0, 0));
}
if (other.name == "pilvi_liila")
{
pilvi_liila_toggle = true;
savu.startColor = new ParticleSystem.MinMaxGradient(liila, new Color(204, 0, 255, 0));
savu2.startColor = new ParticleSystem.MinMaxGradient(liila, new Color(204, 0, 255, 0));
}
}
}
Your answer
Follow this Question
Related Questions
New particle system structs - how does this work? 1 Answer
Random Non-uniform Particle Start Size? 1 Answer
Particle emission on particle collision 2 Answers
Particle system breaks on play 0 Answers