Game Development Community

Jetpack Emitter

by Robert Fritzen · in Torque Game Engine Advanced · 02/15/2011 (9:03 am) · 2 replies

Hello, I'm trying to make a jetpack emitter for my players, and I'm wondering how I'd go about doing that.

So far, I have added the Emitter/ID to the player class

and have added the following to Player::UpdateActionThread()

if(mJetting) {
	     //play the jet emitter
	     Point3F position = getPosition();
         ParticleEmitter * emitter = new ParticleEmitter;
         emitter->onNewDataBlock( mDataBlock->jetEmitter );

		 Con::printf("Doing Jet Emitter Stuff");

         if( !emitter->registerObject() ) {
            Con::warnf( ConsoleLogEntry::General, "Could not register emitter for particle of class: %s", mDataBlock->getName() );
            delete emitter;
            emitter = NULL;
         }
         else {
            emitter->emitParticles( position, Point3F( 0.0, 0.0, -1.0 ), Point3F( 0.0, 0.0, 1.0 ), Point3F( 0, 0, 0 ), 100 );
            emitter->deleteWhenEmpty();
         }
	  }

my test output message is displaying at the correct time, so I'm just wondering what I need to change in my code to properly display the emitter

here is my emitter
datablock ParticleData(JetPackParticle) {
   textureName          = "~/data/shapes/particles/fire";
   dragCoeffiecient     = 0;
   gravityCoefficient   = 0;
   inheritedVelFactor   = 0;
   constantAcceleration = 0;
   lifetimeMS           = 100;
   lifetimeVarianceMS   = 100;
   useInvAlpha =  true;
   spinRandomMin = -300.0;
   spinRandomMax =  300.0;

   colors[0]     = "1 1 1 1";
   colors[1]     = "0.9 0.9 0.9 0.4";
   colors[2]     = "0.7 0.7 0.7 0.0";

   sizes[0]      = 0.2;
   sizes[1]      = 0.6;
   sizes[2]      = 2;

   times[0]      = 0.0;
   times[1]      = 0.2;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(JetPackEmitter) {
   ejectionPeriodMS = 10;
   periodVarianceMS = 2;
   ejectionVelocity = 2;
   velocityVariance = 1;
   thetaMin         = 0.0;
   thetaMax         = 180.0;
   ejectionoffset   = 0.05;
   particles = "JetPackParticle";
};

and my player DB:
datablock PlayerData(SpacesuitData : DefaultPlayerData)
{
   renderFirstPerson = false;
   emap = true;
   
   jumpTowardsNormal = false;
   airControl = 0.3;
   
   jetEmitter = JetPackEmitter;
   
   jetJumpForce       = 8.3 * 10;
   jetJumpEnergyDrain = 0.6;
   jetMinJumpEnergy   = 0;
   
   rechargeRate = 0.35;

   //className = Armor;
   shapeFile = "~/data/shapes/players/Spacesuit/Spacesuit.dts";
};

#1
02/15/2011 (9:38 am)
*Looks* like you're on the right track, but it's been a while since I dealt with adding in jet emitters to the player. It's possible you can look over this for further reference.
#2
02/15/2011 (3:35 pm)
Yeah, that did it for me, thanks!