Controlling Individual Particles In A Unity Particle System

Was playing around with how to get access to the individual particles active in a particle system. I am using one to create some dust in my game and when you die I want to have them stop moving and fall. Here is what the effect looks like:


While I don’t think I am going to use this in the final game I thought I would share the code I used to make it happen. It wasn’t as straightforward as I had hoped to get access to each particle instance.

ParticleSystem.Particle []ParticleList = new    ParticleSystem.Particle[dust.particleCount];
for(int i = 0; i < ParticleList.Length; ++i)
	ParticleList[i].velocity = new Vector3(0,.1f,0);
dust.SetParticles(ParticleList, dust.particleCount);
dust.gravityModifier = 1;

Hope you can find a better use for it than I did.

Lynda Unity 2D Essential Training

Subscribe To My Mailing List

Want to learn how to make a game? Not sure where to start? Even if you are a seasoned game maker there is still a lot you can learn from my mailing list. I'll be covering tips and tricks for how to build, release and market games each month.

Simply sign up for my mailing list and also get access to a 50% off discount code for my eBooks and other content. I promise to not spam your inbox!

Join Now