- Home /
Forcing particle to follow GameObject
I am interested if it is possible to force individual particle, which is inside non moving particle system to follow gameObject?
Answer by DanSuperGP · Jan 28, 2015 at 01:10 AM
Yeah, you can do all sorts of manipulations on your particles with GetParticles and Set Particles.
http://docs.unity3d.com/ScriptReference/ParticleSystem.html
In this case... you would want to get the list of particles with GetParticles... http://docs.unity3d.com/ScriptReference/ParticleSystem.GetParticles.html
Then manipulate the particles in the list that you want to manipulate... http://docs.unity3d.com/ScriptReference/ParticleSystem.Particle.html
Then set the particles afterwards. http://docs.unity3d.com/ScriptReference/ParticleSystem.SetParticles.html
The way it works is a little odd, look at this answer for help with the way to do it.
http://answers.unity3d.com/questions/548164/shuriken-accessing-particle-array-created-in-inspe.html
Wow, thanks for such fast answers. I am actually thinking about possibility to use particles ins$$anonymous$$d of individual sprites for thousands of game objects, which are my soldiers in RTS game. I was wondering if GetParticles and SetParticles calls on almost every update for thousands of particles would be not very expensive? In other words, does anyone know approximate numbers of particles when using GetParticles and SetParticles starts to affect performance?
I think it would be quite expensive depending on what you are doing with the particles in each update step. This is something people use to make their particle effects more visually appealing, like adding vortexes and such... I don't think it's really meant to replace game objects.
Answer by Pflobus · Jan 28, 2015 at 01:02 AM
I don't think it is...I mean you can put the system with the GameObject, in the heirarchy, but I'm not sure. Maybe you could make a cone with a really focused radium pointed in one direction, and have it spew only one particle, and have a long duration, whereas then you have another particle system which is your base system which is stationary and spews like particles to the one that follows the gameObject. Or, you could make one particle system, with just 1 particle, keep it stationary, then put it in the hierarchy to follow the gameObject, and then a separate system, that is stationary, but looks alike. Or some scripting magic, but I'm pretty sure that's about it. But...Google (or Yahoo or Bing (Search Engine Equality)) is (are) your friend(s).