- Home /
Possible to get particle positions with Shuriken?
Is it possible to get particle positions in Shuriken?
I know the old particle system could do this, allowing for 'collectable particles', like in the Penelope tutorial. If Shuriken can't, would there be any issues with me using the old system? (I'm unfamiliar with either currently).
Is my only alternative to create my 'collectable particles' manually as scripted prefabs? I don't $$anonymous$$d doing this, but am just wondering if there would be any performance loss in doing it this way as opposed to using the particle system as the Penelope tutorial does...
Answer by Wolfram · Jun 21, 2012 at 11:43 PM
Doesn't ParticleSystem.GetParticles() and ParticleSystem.Particle.position do what you want?
Hmm… I looked into that but there's no clear documentation on how to use them… I'll see if I can figure it out.
I haven't worked with Shuriken yet, but it should be completely analogous to the old version, which used direct assignment from/to myParticleEmitter.particles, and myParticle.position.
Okay I think I have figured it out. To store the particles into an array, first you need to create an array then send the array within the ParticleSystem.GetParticles() function. Like below:
var particleTotal = 7;
private var particles = new ParticleSystem.Particle[particleTotal];
function Update ()
{
particlesLength = particleSystem.GetParticles(particles);
Debug.Log( particles[0].position );
}
It needs to be in the Update loop because the number of particles obviously changes over time
In case someone wants to change those values, you need to use the ParticleSystem.SetParticles() function after changing the values from the collected Array.