Game Development Community

Fading Emitters?

by Nicolai Dutka · in Torque Game Engine · 09/04/2007 (6:14 am) · 12 replies

I need a "fading emitter" effect.

I am firing a cannon and the ball is supposed to have a smoke trail. The cannon ball is also our player, not a projectile. I have figured out how to get a particle emitter to follow the player, but now I want the smoke to fade out after a couple seconds. What would be a good approach to achieving these results?

#1
09/04/2007 (6:25 am)
Couldn't you just alter the lifetime property accordingly?
#2
09/04/2007 (12:21 pm)
I am actually not the one in charge of fx for this project. The one in charge said he wasn't able to change the lifetime once it has been created. If this is not true, let me know and I'll see what I can do.
#3
09/04/2007 (9:03 pm)
There are different emitter stages that can have independent alpha settings and color. You just change the color settings and the time for each stage governs when it will fade out. I would suggest searching on emitters or picking up "The Game Programmer's Guide to Torque" or "3D Game Programming All In One". Both books cover emitters. What you are describing is already in the emitter capabilities.
#4
09/05/2007 (3:03 pm)
My fx guy says he wasn't able to adjust the start/end times of the color faders after the emitter had already been created. I did give him a "dirty" solution for now that is working.

I created a function that has a loop and a counter. Each time the loop cycles, the emitter is deleted, the faders changed, and the emitter recreated. I thought this would be hard on CPU cycles, but since we don't really have much else going on in the game at the time of this effect, it seems to work nicely.

If someone can tell me of a "cleaner" method of getting the effect we want without using as much CPU power, let me know! :D
#5
09/05/2007 (3:04 pm)
My first post was wrong, it's not supposed to fade out "after" a couple seconds, it's supposed to slowly fade out "over the course" of a few seconds....
#6
09/05/2007 (6:06 pm)
Posted earlier, thinking it was about the TGB editors, sorry to those whom it might have misled in some way!
:)
#7
09/07/2007 (7:43 pm)
I still do not understand why you can't do it. Are you trying to make it variable after you create your object or do you have a predefined time that the object must fade out over?

This will fade from white to clear over particle lifetime:
datablock ParticleData(PD0)
{

// other parameters

colors[0] = "1.0 1.0 1.0 1.0";
colors[1] = "1.0 1.0 1.0 0.0";
colors[2] = "1.0 1.0 1.0 0.0";  // ignored
sizes[0] = 1;
sizes[1] = 1;
sizes[2] = 1; // ignored
times[0] = 0.0;
times[1] = 1.0;
times[2] = 1.0; // ignored

// other parameters
};
#8
09/09/2007 (6:40 pm)
I'm not sure that i got it all right, u want the emitter itself to fade away, not the particles right ???
if so .... & I suppose that u really can't change the emitter once it has been created so, u may change ur loop to a scheduled exectution using the "schedule" function recursively, that should be controlled in a way & wont consume all the CPU time

but still I'm not sure thats the best way to do it, but its an optimized dirty way
#9
09/09/2007 (7:09 pm)
We want the emitter to, slowly and over time based on a variable, reduce the amount of particles it is spitting out until eventually it is not spitting any at all.
#10
09/10/2007 (2:25 am)
There is a variable in the particleemitterdata named "lifetimeMS" takes a positive value [0, inf ) its default is 0 & its the lenght of time to eject particles before stopping (in milliseconds) 0 is always on otherwise for that time in msec
there is another called lifetimeVariance, positive value too, & def is 0
& as mentioned b4 in this post there are 4 groups of colors, sizes & times to set the 4 phases of the emitter
so that would make ur fading effect.
#11
09/10/2007 (2:30 am)
All those mentioned are parameters to be set in the particleemitterdata datablock (lifetimeMS & lifetimeVariance) & the Particledata datablock (clors, sizes, times)
#12
09/10/2007 (2:31 am)
Ok tyvm! i will have a look at this with my fx guy tomorrow and see why he cant get it working.