Delete particles after delay.
by RageO · in Torque Game Engine · 10/24/2006 (11:51 pm) · 3 replies
In the below function I am deleting the logo on collision then creating a particle emitter where my logo used to be.
Problem I want to delete the particle emitter after a few seconds. I want to hit the object, delete the object, then spray some particles, then delete the particles.
I have all of that but I cannot figure out how to delete the particles. And I cannot figure out how to do that after a few seconds. Ive looked up the schedule command and the wait thing. But every time I put some code in there to do this the script crashes.
here is the function
//-----------------------------------------------------------------
function logo::onCollision( %this, %obj, %col)
{
new ParticleEmitterNode(Itworks)
{
position = %obj.getPosition();
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "1";
};
%obj.delete();
}
//------------------------------------------------------------------
What code do I put in there to delete the particle emitter after a few seconds delay ?
Problem I want to delete the particle emitter after a few seconds. I want to hit the object, delete the object, then spray some particles, then delete the particles.
I have all of that but I cannot figure out how to delete the particles. And I cannot figure out how to do that after a few seconds. Ive looked up the schedule command and the wait thing. But every time I put some code in there to do this the script crashes.
here is the function
//-----------------------------------------------------------------
function logo::onCollision( %this, %obj, %col)
{
new ParticleEmitterNode(Itworks)
{
position = %obj.getPosition();
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "1";
};
%obj.delete();
}
//------------------------------------------------------------------
What code do I put in there to delete the particle emitter after a few seconds delay ?
#2
10/25/2006 (12:29 am)
Oh yes and tge 1.5 is out, check out the snapshot page!
#3
Thanks alot!!
and 1.5 looks great. I get it since I just bought torque. Really nice of the guys to do that !!! I love this engine.
Cant download the new one untill I get home in 2 weeks though :(
Oh for those trying to add a delay with schedule here is what I have that works fine.
//-----------------------------------------------------------------
function logo::onCollision( %this, %obj, %col)
{
schedule( 10000 ,0,kill,%obj);
new ParticleEmitterNode(Itworks)
{
position = %obj.getPosition();
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "1";
};
// TO DO: Add code here to have the player react to touching the power-up!
}
function kill(%obj)
{
%obj.delete();
}
//----------------------------------------------------------------------
This is done off of the getting started turorial. This code will make a particle emitter once youve collided with the logo(Provided that you ripped the particle scripts from the fps starter and added the exec commands in your game.cs) Then it will delete the logo after 10 seconds. You can just change it to make it delete what you want.
10/25/2006 (1:06 am)
Sweet I got it firgure out I just had the syntax wrong.Thanks alot!!
and 1.5 looks great. I get it since I just bought torque. Really nice of the guys to do that !!! I love this engine.
Cant download the new one untill I get home in 2 weeks though :(
Oh for those trying to add a delay with schedule here is what I have that works fine.
//-----------------------------------------------------------------
function logo::onCollision( %this, %obj, %col)
{
schedule( 10000 ,0,kill,%obj);
new ParticleEmitterNode(Itworks)
{
position = %obj.getPosition();
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "1";
};
// TO DO: Add code here to have the player react to touching the power-up!
}
function kill(%obj)
{
%obj.delete();
}
//----------------------------------------------------------------------
This is done off of the getting started turorial. This code will make a particle emitter once youve collided with the logo(Provided that you ripped the particle scripts from the fps starter and added the exec commands in your game.cs) Then it will delete the logo after 10 seconds. You can just change it to make it delete what you want.
Torque Owner Mark Junior
that will make the particle delete in 200 miliseconds.
dont know if i wrote it correct though