Game Development Community

Particles Not Auto-Mounting Properly through Script...

by Dave Calabrese · in Torque Game Builder · 12/06/2006 (4:49 pm) · 2 replies

I'm having a weird problem that if I create a particle from the console, it generates itself properly at the path, connects itself to the path, and moves along the path. However, if I use the same code in script, it generates the particle at the top-left corner of the screen, then transitions it to the location on the path that it should be, where it then connects and moves. Why would it do this?

Here is the code I am typing into the console:
$test = new t2dParticleEffect(){scenegraph = activeScenegraph;};$test.loadEffect("data/particles/selectedButtonParticles_Emitter.eff");$test.playEffect();pathA.attachObject($test,20,0,1,1,1,0,1);

And the function that does the same thing, only places the particle in the wrong place:
function menu_makeButtonParticlesOnButton(%buttonNumber)
{
    switch(%buttonNumber)
	{
		case 1: %pathName = pathA;
		case 2: %pathName = pathB;
		case 3: %pathName = pathC;
		case 4: %pathName = pathD;
		case 5: %pathName = pathE;
	}
	
   %particle1 = new t2dParticleEffect() 
   {
      scenegraph = activeScenegraph; 
   };
   %particle1.loadEffect("data/particles/selectedButtonParticles_Emitter.eff");
   %particle1.playEffect();
   %pathName.attachObject(%particle1,25,0,0,1,1,0,1);

   %particle2 = new t2dParticleEffect() 
   {
      scenegraph = activeScenegraph; 
   };
   %particle2.loadEffect("data/particles/selectedButtonParticles_Emitter.eff");
   %pathName.attachObject(%particle2,25,0,4,1,1,0,1);
   %particle2.playEffect();

}

Any thoughts? Comments? Advice? Cows?

#1
12/10/2006 (6:01 am)
I don't know if this is relevant, but I noticed that playEffect is called on %particle1 before it's attached to the path.
#2
12/10/2006 (6:10 am)
...another thought: if switching that order doesn't work, try delaying all the playEffect calls until the next scene update. You can do this using the 'schedule 0' method.

Here's an example:

%particle1.schedule(0, playEffect);

The idea is that if paths work like mounting, which I suspect they do, the emitter might be updating before it's position is modified by the path.