Game Development Community

Concurrent Particle Emitter Problem

by Matt McCracken · in Torque Game Builder · 03/17/2006 (3:51 pm) · 1 replies

The function below creates the particles to generate a firework. It looks pretty badass; but there's a problem I have that I can't seem to solve(two actually).

1) the "streaks" fire before the firework itself. Basically, you get this pretty streaky type effect and then about a half second later the actual firework parts fire off. I think this is strange because all of the "streaks" fire together, and all of the "emitter" fire together, but they both seem to kick off at different times. Any idea how I can get them to sync so they both fire at the same time?

2) obviously this function creates a bunch of particles...they don't seem to be getting deleted. That is, when I watch the memory that T2D is using while I fire off this function, it keeps increasing and never decreasing. Am I missing some important cleanup step?

Thanks in advance for any help.

Quote:
function createFireWork(%particles, %particleForce, %minAngle, %maxAngle, %red, %green, %blue)
{%degrees = %maxAngle-%minAngle;

if(%particles>%degrees)
{%particles=%degrees;}

%anglePerParticle=%degrees/%particles;

%fireWork=new t2dparticleeffect() {sceneGraph=t2dscene;};
%fireWork.setEffectLifeMode(Kill,1.0);

for(%count=0;%count<=%particles;%count++)
{%ember=new t2dParticleEffect() {sceneGraph = t2dScene;};


%emitter = %fireWork.addEmitter();
%streaks = %fireWork.addEmitter();

%emitter.setImageMap(fireworkParticle);
%streaks.loadEmitter("~/data/particles/streaks.emi");

if(%red$="R")
{%red_life=getRandom(0,999)/1000;}
else
{%red_life=%red;}

if(%blue$="R")
{%blue_life=getRandom(0,999)/1000;}
else
{%blue_life=%blue;}

if(%green$="R")
{%green_life=getRandom(0,999)/1000;}
else
{%green_life=%green;}

%emitter.setUseEffectEmission(false);
%streaks.setUseEffectEmission(False);

%emitter.selectGraph("emissionAngle_var");
%emitter.clearDataKeys();
%emitter.setDataKeyValue(0,0);

%streaks.selectGraph("emissionAngle_var");
%streaks.clearDataKeys();
%streaks.setDataKeyValue(0,0);

%emitter.selectGraph("emissionForce_base");
%emitter.clearDataKeys();
%emitter.setDataKeyValue(0,%particleForce);

%streaks.selectGraph("emissionForce_base");
%streaks.clearDataKeys();
%streaks.setDataKeyValue(0,%particleForce);

%emitter.selectGraph("emissionAngle_base");
%emitter.clearDataKeys();
%emitter.setDataKeyValue(0,(%count*%anglePerParticle)+%minAngle);

%streaks.selectGraph("emissionAngle_base");
%streaks.clearDataKeys();
%streaks.setDataKeyValue(0,(%count*%anglePerParticle)+%minAngle);

%emitter.selectGraph("quantity_base");
%emitter.clearDataKeys();
%emitter.setDataKeyValue(0,1);

%emitter.selectGraph("red_life");
%emitter.clearDataKeys();
%emitter.setDataKeyvalue(0,%red_life);

%streaks.selectGraph("red_life");
%streaks.clearDataKeys();
%streaks.setDataKeyvalue(0,%red_life);

%emitter.selectGraph("green_life");
%emitter.clearDataKeys();
%emitter.setDataKeyvalue(0,%green_life);

%streaks.selectGraph("green_life");
%streaks.clearDataKeys();
%streaks.setDataKeyvalue(0,%green_life);

%emitter.selectGraph("blue_life");
%emitter.clearDataKeys();
%emitter.setDataKeyvalue(0,%blue_life);

#1
03/17/2006 (3:51 pm)
Continued...

Quote:
%streaks.selectGraph("blue_life");
%streaks.clearDataKeys();
%streaks.setDataKeyvalue(0,%blue_life);

%emitter.selectGraph("visibility_life");
%emitter.clearDataKeys();
%emitter.addDataKey(0,1);
%emitter.addDataKey(0.2,0.8);
%emitter.addDataKey(0.4,0.6);
%emitter.addDataKey(0.6,0.4);
%emitter.addDataKey(0.8,0.2);
%emitter.addDataKey(1,0);

%emitter.selectGraph("speed_life");
%emitter.clearDataKeys();
%emitter.addDataKey(0,%particleForce);
%emitter.addDataKey(0.2,0.1);
// %emitter.addDataKey(0.65,0.4);
// %emitter.addDataKey(1,0.0);

%streaks.selectGraph("visibility_life");
%streaks.clearDataKeys();
%streaks.addDataKey(0,1);
%streaks.addDataKey(0.2,0.8);
%streaks.addDataKey(0.4,0.6);
%streaks.addDataKey(0.6,0.4);
%streaks.addDataKey(0.8,0.2);
%streaks.addDataKey(1,0);

%emitter.selectGraph("fixedForce_base");
%emitter.clearDataKeys();
%emitter.setDataKeyvalue(0,5);
%emitter.setFixedForceAngle(180);

%streaks.selectGraph("fixedForce_base");
%streaks.clearDataKeys();
%streaks.setDataKeyvalue(0,1);
%streaks.setFixedForceAngle(180);

%emitter.selectGraph("particleLife_base");
%emitter.clearDataKeys();
%emitter.setDataKeyvalue(0,1);

%streaks.selectGraph("particleLife_base");
%streaks.clearDataKeys();
%streaks.setDataKeyvalue(0,1.4);



}


%firework.playEffect(true);
}