Game Development Community

Creating a particle effect in code. [resolved]

by Cosmic Logic · in Torque Game Builder · 05/13/2009 (11:05 pm) · 3 replies

Hey,

I apoligise if this has been answered before, but without the search function on the forums finding anything is way too time consuming.

I'm trying to make and mount a particle effect in code.
Here is what I have:

%county = new t2dParticleEffect(whee) {
      effectFile = "~/data/particles/superShotCount.eff";
      useEffectCollisions = "0";
      effectMode = "KILL";
      effectTime = "9.5";
      size = "10 10";
      CollisionMaxIterations = "1";
   };
	%county.mount(%this.owner, 1,0,0,true,true,true,true);

I get nothing with that. I've also tried this to just put it in the center of the screen.

%county = new t2dParticleEffect(whee) {
      effectFile = "~/data/particles/superShotCount.eff";
      useEffectCollisions = "0";
      effectMode = "KILL";
      effectTime = "9.5";
		position = "0 0";
      size = "10 10";
      CollisionMaxIterations = "1";
   };

I've also tried it without using the %county, just having new t2dParticleEffect.. etc.

Not sure what I'm doing wrong here, if anyone could point me in the right direction that would be great.

#1
05/14/2009 (1:20 am)
You haven't add it to the scene graph. Try adding

new t2dParticleEffect() 
{  
  scenegraph = %this.owner.getSceneGraph(); // Add me!
};
#2
05/14/2009 (4:01 am)
You will also need to set the effect to play:

%myNewEffect.playEffect();
#3
05/14/2009 (12:26 pm)
Beautiful.

Thanks very much guys. It works perfectly.