Find Particle System for use in C# code

So, this is my code for finding it…

ps = gameObject.GetComponent<ParticleSystem>();

let’s say I have a particle system named “Left”… so how do I find it in that code? GetComponent doesn’t let me give a name for it or anything, like how does this work? I wanna be able to do

ps.startColor = something;

to the “Left” particle system. How do I do this? Obviously GameObject.find won’t work since it’s uh… a particle system. (if it matters it’s a parent of a gameobject named blue_falcon)

1 Answer

1

Try this

public GameObject leftParticleGO;
YourScriptName ps;

void Start() {
    ps = leftParticleGO.GetComponent<YourScriptName>();
}

void Func() {
    ps.startColor = something;
}

leftParticleGO - is GO with particle system component

I still don't get it. YourScriptName? What script would that be? I'm using a colorpicker script and this should all hopefully be done in the same script. EDIT: okay i think i kinda got it. i made a sphere and put the script on it, and i was able to fill in the ps field with my target particle system. and i replaced yourscriptname with ParticleSystem. However the color still isn't changing! I also changed func to Update EDIT: finally got it. thanks :)

–

I'm happy to help =)

–