I may be missing something obvious, but last night i couldn’t figure out how to gain access to ParticleSystem attached to some object.
i have two objects: xform1 and xform2
xform1 has a script attached
xform2 has a ParticleSystem (shuriken) attached
i want to be able to trigger particle emission from the xform1’s script when some button is pressed.
The problem is that i cannot figure out how to access the ParticleSystem on the other object - xform2
Tried so many things (getComponent variations) but always get null pointers.
Can somebody provide an example how to gain access to a ParticleSystem located on an object from script attached to another object ?
Thanks.
Were you using getComponent or GetComponent?
I use gameObject.GetComponent.
var go : GameObject;
private var ps : ParticleSystem;
ps = go.GetComponent(ParticleSystem);
ps = go.GetComponent(“MyParticleSystem”);
etc …
I don’t get syntax errors. Just not getting the data properly.
Also the component class has particleSystem attribute that should give me the particle system attached to the game object. But not sure how to make use of that too.
This is my second day in Unity and i really like what i see there.
Got some ships flying around shooting at each other, etc.
Started refining some things and hit that ParticleSystem problem.
Found some examples online but they are all about the “old” particles.
Thanks.