Game Development Community

Particles, how to set the up ???

by Bruno · in Torque Game Builder · 07/24/2006 (10:11 am) · 1 replies

Hi,

I've been messing around with the particle engine, and i'm tryng to load one trough script, and i keep getting this error in the console :

t2dParticleEffect::loadEffect() - Cannot Load-Effect; not in a scene!
t2dParticleEffect::playEffect() - Cannot Play; no emitters!

I'm loading it like this :

%explosion = new t2dParticleEffect() 
            {
              scenegraph = %this.scenegraph; 
            };
   
            %explosion.loadEffect("~/data/particles/enemyExplosion.eff");
            %explosion.setEffectLifeMode("KILL", 1);
            %explosion.setPosition(%x,%y);
            %explosion.playEffect();


As i see, he expects me to inside TGB to drag and drop a particle system into my workspace, but i know it has
to be some other solution to this, i can't imagine that if i need 20 explosions, i need to be dragging and droping all the particle systems that i will use in the game to the workspace.., right ?

thanks,
Bruno

#1
07/24/2006 (10:47 am)
What does your actual function look like? If your function header doesn't have some thing like: t2dStaticSprite::LoadEffect(%this) --(LoadEffect is just a name that I made up) then %this doesn't mean anything. %this is the instance that is calling the function based on its class.

One way to fix your problem is to go into the level editor, click on the tab that says Project, then click on the SceneGraph(it should be the top one). Once your there, go into the Edit tab and then the SceneGraph Scripting tab, then make the name: MySceneGraph. Then make your one section of code:

%explosion = new t2dParticleEffect()
{              
         scenegraph = MySceneGraph;             
};


Keep in mind all your variables either must be passed in to the function, or defined in the function, or be Global variables.

In the code sample you have above, %x and %y aren't defined, as far as I can tell.

Torque Script takes a while to get used to, but just keep the TGB Reference handy and have patience, and you'll get used to it soon enough.