- Home /
How to get a list of particles
How to get a list of particles from a particle system? Like the particle emitter has a option named .particles.
Answer by robertbu · Oct 10, 2014 at 05:31 PM
The setup:
#pragma strict
var ps : ParticleSystem;
var particles : ParticleSystem.Particle[];
function Start() {
ps = particleSystem;
particles = new ParticleSystem.Particle[ps.maxParticles];
}
Then to get the particles:
var count = ps.GetParticles(particles);
You will find the definition of a ParticleSystem.Particle here:
http://docs.unity3d.com/ScriptReference/ParticleSystem.Particle.html
So given an array, you can get the position of the first particle in the array by:
var pos = particles[0].position;
Note that the index frame to frame does not remain constant. That is, the particle that was in the particles[0] slot one frame may be in a different slot in the array or not exist at all in some future frame. The array is a snapshot of the current frame.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Javascript containing List<> - can not make them work in WebPlayer 1 Answer
How to Activate Particle System? 0 Answers
Cooking System Help 1 Answer