- Home /
Applying Outside Direction to Particles
I'm building a top-down scrolling game and would like to be able to move individual particles along with the map's scrolling movement.
An example would be a ParticleSystem attached to a tank. The particles would emit from the tank as it moves around but since the parent of the system is the tank, the particles emit and then follow the tank around rather than following the scroll of the map. Changing the simulation space to World doesn't work because while the map is scrolling, the camera is in a fixed position with the tiles being rather than the camera scrolling around the world space.
I think the easiest solution would be to modify the transform of each individual particle every update with the direction the map is scrolling but I can't figure out how to gain access to the individual particle's transforms.
Any help would be greatly appreciated. Thanks!
Why don't you use an empty game object whose transform is set at the edge of your screen's height and child the particle system on it?
If I misunderstood, I need some help visualizing what you want to achieve.

$$anonymous$$aybe this might clear it up a bit. I need the smoke particles that are emitting from the tank to follow the ground after it's been emitted from the tank rather than being attached to the tank. If I could access the transforms of the individual particles, I should be able to do it pretty easily but I don't know how to get at the properties I need.
Answer by Fobwashed · Apr 10, 2015 at 04:19 AM
Figured it out.
public ParticleSystem particle;
ParticleSystem.Particle[] particles;
void Start ()
{
particles = new ParticleSystem.Particle[particle.maxParticles];
}
void Update ()
{
//Get Particles out of Particle system and into your array. int numParticlesAlive = particle.GetParticles(particles);
for(int i = 0; i < numParticlesAlive; i++)
{ modify particles in whatever way you need }
//put modified particles back into particle system. particle.SetParticles(particles, numParticlesAlive); }
Your answer