- Home /
How do I accelerate particles in Shuriken?
I'd like to create a burst effect that starts slowly but explodes quickly, but I haven't found anything that can change the speed over time....
I tried these things, and none of them works:
Velocity over Lifetime: this module messes up the direction of the burst.
Limit Velocity over Lifetime: as it says, it only limits the velocity but never increase it. This works perfect with slowing, how about the opposite?
Force over Lifetime: this also messes up the direction.
Change start speed to curve instead of a constant: I cannot see the reason why it can be curve. Apparently this only sets the initial speed, and only the first point of the curve matters.
Did I miss anything? Or it's just impossible to set the speed of particles?
Answer by brilliancenp · Feb 26, 2014 at 11:06 PM
I would develop your own behavior to put on your particle system. Use the :
ParticleSystem.Particle[] particles = new ParticleSystem.Particle[particleSystem.particleCount];
particleSystem.GetParticles(particles);
Now you have an array of every particle in the system. Each particle if you iterate through it can be individually changed:
for(int p = 0; p < particles.Length; p++)
{
ParticleSystem.Particle part = particles[p];
//now you can adjust anything
//part.velocity is going to be what you want but there are other adjustments to be
//made check out https://docs.unity3d.com/Documentation/ScriptReference/ParticleSystem.Particle.html
//update your array with the updated particle
particles[p] = part;
}
//set your array back to the particleSystem
particleSystem.SetParticles(particles, particles.Length);
Let me know if you have any questions about this or if this is not what you are looking for.
Is this the only way to do the acceleration? Iterating through all alive particles seems inefficient.
This is the way I know how. It is really not inefficient at all. You are basically taking over the particle system. The particle system is doing this whether you do it or not. I do this alot with hundreds, sometimes thousands of particles, sometimes with lifetimes that are very long with no drop in frames. A ParticleSystem.Particle is not a class or an object it is a struct so there is not a whole lot of overhead.
Sounds good! Originally I though such operations might be expensive, so I just tried to ask a better one here... Thanks for your help!