Game Development Community

ParticleEmitter problems

by Ian Omroth Hardingham · in Torque Game Engine · 01/13/2005 (6:50 am) · 1 replies

Hey everyone.

I'm having problems with a particle emitter in my player class.

I create it by:

if (isClientObject())
   {
      mDeathParticleEmitter = new ParticleEmitter;

      ParticleEmitterData* ped;

      if (Sim::findObject("PlayerDeathEmitter", ped))
      {
         mDeathParticleEmitter->onNewDataBlock( ped );
         
         if( !mDeathParticleEmitter->registerObject() )
         {
            Con::errorf("Could not register death emitter for player");
            delete mDeathParticleEmitter;
            mDeathParticleEmitter = 0;
         }
      }
      else
         Con::errorf("Couldnt find the death particle datablock");
   }

and use it with:

mDeathParticleEmitter->emitParticles( emitterLoc, emitterLoc, Point3F( 0.0, 0.0, 1.0 ),
                   VectorF(0,0,0), (U32)(32));

and then, to remove it, I do:

if (mDeathParticleEmitter)
   {
      delete mDeathParticleEmitter;
      mDeathParticleEmitter = 0;
   }

In the player destructor. However, whenever I leave the game I get an assert fatal telling me I haven't removed the ParticleEmitter, and sometimes the game crashes with "Particles still in Emitter?".

Can anyone point me in the direction of what's going on?

Ian

#1
01/13/2005 (5:35 pm)
Try changing this:

if (mDeathParticleEmitter)
{ delete mDeathParticleEmitter;
mDeathParticleEmitter = 0;
}

...to this:

if (mDeathParticleEmitter)
{ delete mDeathParticleEmitter;
mDeathParticleEmitter = 0;
echo("destroyed the mDeathParticleEmitter");
}

Do you see that echo when someone dies or leaves the game? I don't know what your problem is, but this is the first thing I would try in order to fix it. There are two possibilities, as I see it: (1) your delete code doesn't run or (2) your delete code is malfunctioning. By adding an echo statement, you can learn which one it is.