Game Development Community

Particle Effects not working

by Adam Beer · in Torque Game Engine · 09/23/2007 (9:12 am) · 7 replies

I created a new set of particle effects for my game and I get this error every time I set the projectile explosion to use one of them:

Object 'GrenadeExplosion' is not a member of the 'ExplosionData' data block class

All my new explosions are setup in their own script files because I thought it would be easier to use them that way. I cant get any of them to work. The emitters show up in the world editor so I can create them but the actual explosion wont. Any ideas?

#1
09/23/2007 (3:48 pm)
Its sounds like u've got a syntax error in the script, would u post the code on the forum so we could check it out
(add [code] before it & ["/"code] after it without the quotes)
#2
09/23/2007 (5:18 pm)
Here you go:

datablock ParticleData(grenadeDebrisTrail)
{
   textureName          = "~/data/shapes/particles/smoke01";
   gravityCoefficient   = 0;
   lifetimeMS           = 1200;
   lifetimeVarianceMS   = 600;
   spinRandomMin = -180.0;
   spinRandomMax =  180.0;
   useInvAlpha   = true;

   colors[0]     = "1.0 0.9 0.8 0.2";
   colors[1]     = "0.8 0.8 0.8 0.3";
   colors[2]     = "0.4 0.4 0.4 0.0";

   sizes[0]      = 0.4;
   sizes[1]      = 2.0;
   sizes[2]      = 4.0;

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

datablock ParticleEmitterData(grenadeDebrisTrailEmitter)
{
   ejectionPeriodMS = 6;
   periodVarianceMS = 2;
   ejectionVelocity = 1.0;
   velocityVariance = 0.8;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   particles = "grenadeDebrisTrail";
};

datablock ParticleData(grenadeSubFireball)
{
   textureName          = "~/data/shapes/particles/explosion";
   dragCoeffiecient     = 0.0;
   gravityCoefficient   = -3;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   lifetimeMS           = 300;
   lifetimeVarianceMS   = 100;
   useInvAlpha =  false;
   spinRandomMin = -280.0;
   spinRandomMax =  280.0;

   colors[0]     = "1.0 0.9 0.8 0.1";
   colors[1]     = "1.0 0.5 0.0 0.3";
   colors[2]     = "0.1 0.1 0.1 0.0";

   sizes[0]      = 1.0;
   sizes[1]      = 2.0;
   sizes[2]      = 3.0;

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

datablock ParticleEmitterData(grenadeSubFireballEmitter)
{
   ejectionPeriodMS = 10;
   periodVarianceMS = 5;
   ejectionVelocity = 3.5;
   velocityVariance = 2.0;
   thetaMin         = 0.0;
   thetaMax         = 120.0;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   ejectionoffset   = 2;
   particles = "grenadeSubFireball";
};

datablock ParticleData(grenadeSubSmoke)
{
   textureName          = "~/data/shapes/particles/smoke01";
   dragCoeffiecient     = 0.0;
   gravityCoefficient   = -0.4;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   lifetimeMS           = 700;
   lifetimeVarianceMS   = 200;
   useInvAlpha =  false;
   spinRandomMin = -120.0;
   spinRandomMax =  120.0;

   colors[0]     = "0.8 0.7 0.6 0.3";
   colors[1]     = "0.9 0.9 0.9 0.8";
   colors[2]     = "0.9 0.9 0.9 0.0";

   sizes[0]      = 2.0;
   sizes[1]      = 4.0;
   sizes[2]      = 7.0;

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

datablock ParticleEmitterData(grenadeSubSmokeEmitter)
{
   ejectionPeriodMS = 30;
   periodVarianceMS = 10;
   ejectionVelocity = 1.5;
   velocityVariance = 0.5;
   thetaMin         = 0.0;
   thetaMax         = 90.0;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   ejectionoffset   = 2;
   particles = "grenadeSubSmoke";
};

datablock ParticleData(grenadeSparks)
{
   textureName          = "~/data/shapes/particles/spark";
   gravityCoefficient   = 0.0;
   inheritedVelFactor   = 0.4;
   lifetimeMS           = 100;
   lifetimeVarianceMS   = 10;
   useInvAlpha =  false;
   spinRandomMin = -0.0;
   spinRandomMax =  0.0;

   colors[0]     = "1.0 0.9 0.8 0.2";
   colors[1]     = "1.0 0.9 0.8 0.8";
   colors[2]     = "0.8 0.4 0.0 0.0";

   sizes[0]      = 1.0;
   sizes[1]      = 2.5;
   sizes[2]      = 2.0;

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

datablock ParticleEmitterData(grenadeSparksEmitter)
{
   ejectionPeriodMS = 10;
   periodVarianceMS = 2;
   ejectionVelocity = 60;
   velocityVariance = 4;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   orientParticles  = true;
   orientOnVelocity = true;
   particles = "grenadeSparks";
};

datablock ParticleData(grenadeSmoke)
{
   textureName          = "~/data/shapes/particles/smoke01";
   dragCoeffiecient     = 0.0;
   gravityCoefficient   = -0.1;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   lifetimeMS           = 1200;
   lifetimeVarianceMS   = 600;
   useInvAlpha =  true;
   spinRandomMin = -80.0;
   spinRandomMax =  80.0;

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

   sizes[0]      = 2.0;
   sizes[1]      = 5.0;
   sizes[2]      = 8.0;

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

datablock ParticleEmitterData(grenadeSmokeEmitter)
{
   ejectionPeriodMS = 15;
   periodVarianceMS = 5;
   ejectionVelocity = 2.0;
   velocityVariance = 1.0;
   thetaMin         = 0.0;
   thetaMax         = 180.0;
   ejectionOffset   = 1;
   particles = "grenadeSmoke";
};

datablock ParticleData(grenadeFireball)
{
   textureName          = "~/data/shapes/particles/explosion";
   dragCoeffiecient     = 0.0;
   gravityCoefficient   = -0.5;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   lifetimeMS           = 400;
   lifetimeVarianceMS   = 200;
   useInvAlpha =  false;
   spinRandomMin = -180.0;
   spinRandomMax =  180.0;

   colors[0]     = "1.0 0.9 0.8 0.9";
   colors[1]     = "0.8 0.4 0 0.3";
   colors[2]     = "0.0 0.0 0.0 0.0";

   sizes[0]      = 2.0;
   sizes[1]      = 7.0;
   sizes[2]      = 4.0;

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

datablock ParticleEmitterData(grenadeFireballEmitter)
{
   ejectionPeriodMS = 10;
   periodVarianceMS = 5;
   ejectionVelocity = 3;
   velocityVariance = 2;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   particles = "grenadeFireball";
};


datablock DebrisData(grenadeDebris)
{
   shapeFile = "~/data/shapes/explosiondebris/grenadedebris.dts";
   emitters = "grenadeDebrisTrailEmitter";
   
   elasticity = 0.6;
   friction = 0.5;
   numBounces = 1;
   bounceVariance = 1;
   explodeOnMaxBounce = true;
   staticOnMaxBounce = false;
   snapOnMaxBounce = false;
   minSpinSpeed = 300;
   maxSpinSpeed = 700;
   render2D = false;
   lifetime = 0.15;
   lifetimeVariance = 0.0;
   velocity = 40;
   velocityVariance = 10;
   fade = true;
   useRadiusMass = true;
   baseRadius = 0.3;
   gravModifier = 0;
   terminalVelocity = 40;
   ignoreWater = false;
};

//grenade Sub Explosions

datablock ExplosionData(grenadeSubExplosion1)
{
   lifeTimeMS = 80;
   offset = 0.2;
   emitter[0] = grenadeSubFireballEmitter;
};


datablock ExplosionData(grenadeSubExplosion2)
{
   lifeTimeMS = 80;
   offset = 0.5;
   emitter[0] = grenadeSubFireballEmitter;
   emitter[1] = grenadeSubSmokeEmitter;
};



datablock ExplosionData(grenadeExplosion)
{
   //soundProfile = CrossbowExplosionSound;
   lifeTimeMS = 80;

   // Volume
   particleEmitter = grenadeSmokeEmitter;
   particleDensity = 10;
   particleRadius = 0.6;

   // Point emission
   emitter[0] = grenadeFireballEmitter; 
   emitter[1] = grenadeSubFireballEmitter; 
   emitter[2] = grenadeSparksEmitter;
   emitter[3] = grenadeSparksEmitter; 


   // Sub explosions
   subExplosion[0] = grenadeSubExplosion1;
   subExplosion[1] = grenadeSubExplosion2;
   

   // Exploding debris
   debris = grenadeDebris;
   debrisThetaMin = 0;
   debrisThetaMax = 90;
   debrisPhiMin = 0;
   debrisPhiMax = 360;
   debrisNum = 8;
   debrisNumVariance = 2;
   debrisVelocity = 1;
   debrisVelocityVariance = 0.2;
};
#3
09/24/2007 (12:36 am)
Well, from the look of it the file looks fine, & I suppose that there is no errors in the file, but I can't be sure of that, so double check that there is no compilation errors (clear DSOs better) & make sure that u actually "exec" this file !!
#4
09/24/2007 (12:55 am)
I've experienced the same error message when a function called for the particle data before it was created. I.e. try re-ordering the execution of your scripts. If this is for a weapon, then execute the corresponding weapon script before this one. If need be simply shift the particle data to the top of the file if it isn't already.

The order in which you create datablocks and execute scripts does matter.
#5
09/24/2007 (4:38 am)
I have tryed moving the particle data and the script executes after the weapons. Nothing works. I will try moving the particle scripts to execute before the weapons and see if that works.
#6
09/24/2007 (4:42 am)
Oops, that's what I meant to write above - execute the particle data before the weapon script.
#7
09/24/2007 (2:07 pm)
Thanks Tim. That did it. I think this should be classed as a bug because no matter what order the scripts are loaded in it should still work properly.