Game Development Community

Reverse particles

by Marc Olivier · in Torque X 2D · 02/05/2009 (2:53 am) · 4 replies

This is something that my group and I have been trying to figure out for a while while working on XNA.

For example, let's take a particle generator that shoots an upward spray of black beads. When the player flips on a switch, the generator now works in reverse: the particles are sucked back in and new ones fade-in from above the generator.

We didn't find a proper way to do this will vanilla XNA, but now that we've switched to Torque X I'd like to know if there is a simple or effective way to achieve this. The integrated particle generator is quite useful, so I'm hoping that we can tinker with it to get this to work.

Any ideas on how to make it happen would be very appreciated :)

#1
02/05/2009 (5:58 am)
Seems like you'd create 2 particle effects. The upward ones and then when the generator turns on destroy the upward particles and put the downward particles in their place. I guess you'd have to keep track of where they are.

Maybe you could even have the 2 particle effects mounted to each other and set either one visible based on the direction they are going.

That of course assumes that you'd expect the particles to look different when they went up vs when they went down. If they look the same, but just change direction you would not need 2 particle effects.

I don't know for sure, just throwing ideas out there. You'd for sure need a component to manage the direction they move and to know when to move and you'd need some kind of messaging system to inform the particles that the fan has turned on. You could get really elaborate and build a message system, or you could do something simple and have a flag that the particle manager keeps checking and that the fan component can modify..

Or forget all that and just have the fan itself manage the particles which sounds like you'd want to do and when the fan is going up the gravity value is 0 on the particles and when it reverses gravity on the particles is higher forcing them to fall back
#2
02/05/2009 (9:09 am)
Build yourself a particle attractor class. Overload the constructor to take a particle and a particle list. Give the class a bool for on/off, a vec3 position property which you can get/set (which you should update for a moving attractor). Add some members to the class to control fading, velocity, random velocity, random dir. If the attractor is on, override the passed in particles' postions each update, moving them closer to the attractor postion, and update their transparency, velocity, direction, etc. and when the particle gets close enough to the attractor, remove it. Consider updating less frequently as the particle list gets larger.
#3
02/06/2009 (2:46 am)
Thank you for the replies :)

The first idea is what more of a backup plan in case everything else fails. The transition between the two sets of particles would be very strange.

I'll run the second idea by our lead programmer to see what he thinks.
#4
02/06/2009 (10:48 am)
I really like Jim's idea for a particle attractor! Great idea!

John K.
www.envygames.com