Particles and triggers
by Shane Culliton · in Game Design and Creative Issues · 08/15/2004 (2:16 pm) · 16 replies
I have a couple of checkpoints through out the games that are set-up using triggers. Is there anyway that i can display a particle effect when i walk into the trigger area and stop it when i leave the trigger area!
About the author
#2
Datablock TriggerData(yourTrig) { tickPeriodMS = 1000; };
function yourTrig::onEnterTrigger(%this, %trigger, %obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
%this.makeEmitter(%trigger);
}
function yourTrig::onLeaveTrigger(%this,%trigger, %obj)
{
Parent::onLeaveTrigger(%this,%trigger,%obj);
%this.StopEmitter(%trigger);
}
function yourTrig::makeEmitter(%this,%obj){
%obj.emitter = new ParticleEmitterNode() { etc };
}
function yourTrig::stopEmitter(%this,%obj) {
%obj.emitter.delete();
}
08/15/2004 (4:22 pm)
It might be a good idea to store the emitter ID in the trigger itself rather than a global. Use the method outlined by Sam but a little different:Datablock TriggerData(yourTrig) { tickPeriodMS = 1000; };
function yourTrig::onEnterTrigger(%this, %trigger, %obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
%this.makeEmitter(%trigger);
}
function yourTrig::onLeaveTrigger(%this,%trigger, %obj)
{
Parent::onLeaveTrigger(%this,%trigger,%obj);
%this.StopEmitter(%trigger);
}
function yourTrig::makeEmitter(%this,%obj){
%obj.emitter = new ParticleEmitterNode() { etc };
}
function yourTrig::stopEmitter(%this,%obj) {
%obj.emitter.delete();
}
#3
How would you delay an event, say based on leaving the trigger?
This results in an unknown command error...
function yourTrig::onLeaveTrigger(%this,%trigger, %obj)
{
Parent::onLeaveTrigger(%this,%trigger,%obj);
schedule(1500, 0, %this.StopEmitter(%trigger));
}
08/15/2004 (6:24 pm)
Thanks Paul. How would you delay an event, say based on leaving the trigger?
This results in an unknown command error...
function yourTrig::onLeaveTrigger(%this,%trigger, %obj)
{
Parent::onLeaveTrigger(%this,%trigger,%obj);
schedule(1500, 0, %this.StopEmitter(%trigger));
}
#4
try change this:
schedule(1500, 0, %this.StopEmitter(%trigger));
to this:
%this.schedule(5000, "StopEmitter", %trigger);
08/16/2004 (1:02 am)
Sam,try change this:
schedule(1500, 0, %this.StopEmitter(%trigger));
to this:
%this.schedule(5000, "StopEmitter", %trigger);
#5
10/12/2004 (7:44 am)
Can you give me an example of what to put in the %obj.emitter = new ParticleEmitterNode() { etc }; to make a FireParticleEmitter start at that trigger when the player walks in to it
#6
position = "886.903 364.721 94.6248";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "0.5";
};
Look in chimneyfire.cs in the example folder to see ChimneySmokeEmitterNode and ChimneySmokeEmitter.
10/12/2004 (8:08 am)
New ParticleEmitterNode() {position = "886.903 364.721 94.6248";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "0.5";
};
Look in chimneyfire.cs in the example folder to see ChimneySmokeEmitterNode and ChimneySmokeEmitter.
#7
Thanks for the response. I added your code and nothing seemed to happen, I gave it the position of my trigger. Here is what I have..
function TokenTrigger::makeEmitter(%this,%obj)
{
echo( "A Blaze should have just happened");
%obj.emitter = New ParticleEmitterNode()
{
position = "68.6944 -168.837 5.7";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "0.5";
echo( "Firing Blaze");
}
};
10/12/2004 (8:19 am)
SamThanks for the response. I added your code and nothing seemed to happen, I gave it the position of my trigger. Here is what I have..
function TokenTrigger::makeEmitter(%this,%obj)
{
echo( "A Blaze should have just happened");
%obj.emitter = New ParticleEmitterNode()
{
position = "68.6944 -168.837 5.7";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "0.5";
echo( "Firing Blaze");
}
};
#8
Don't put an echo in the emitter node. ( "Firing Blaze");
You need a ; at the end of the node
%obj.emitter = New ParticleEmitterNode()
{
position = "68.6944 -168.837 5.7";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "0.5";
};
10/12/2004 (8:51 am)
Does this echo? echo( "A Blaze should have just happened"); Don't put an echo in the emitter node. ( "Firing Blaze");
You need a ; at the end of the node
%obj.emitter = New ParticleEmitterNode()
{
position = "68.6944 -168.837 5.7";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "0.5";
};
#9
Even when I remove echo, it still is not firing nor hitting the echo to let me knoe it ran past that new particleEmitterNode
Here is my new code
function TokenTrigger::makeEmitter(%this,%obj)
{
echo( "Trying to make emitter");
%obj.emitter = new ParticleEmitterNode() {
position = "886.903 364.721 94.6248";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "0.5";
}
echo( "Wraping up Emitter");
}
10/12/2004 (8:54 am)
SamEven when I remove echo, it still is not firing nor hitting the echo to let me knoe it ran past that new particleEmitterNode
Here is my new code
function TokenTrigger::makeEmitter(%this,%obj)
{
echo( "Trying to make emitter");
%obj.emitter = new ParticleEmitterNode() {
position = "886.903 364.721 94.6248";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "0.5";
}
echo( "Wraping up Emitter");
}
#10
%obj.emitter = New ParticleEmitterNode()
{
position = "68.6944 -168.837 5.7";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "0.5";
};
10/12/2004 (8:57 am)
You need a ; at the end of the node%obj.emitter = New ParticleEmitterNode()
{
position = "68.6944 -168.837 5.7";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "ChimneySmokeEmitterNode";
emitter = "ChimneySmokeEmitter";
velocity = "0.5";
};
#11
Sorry buddy
I had forgotten the ";" after that function
works like a charm
Thanks for your help!
10/12/2004 (8:58 am)
SamSorry buddy
I had forgotten the ";" after that function
works like a charm
Thanks for your help!
#12
I bet that error showed up in the console output, towards the top, nicely highlighted in red ... or not. ;)
10/12/2004 (9:38 am)
Glad it works now. I bet that error showed up in the console output, towards the top, nicely highlighted in red ... or not. ;)
#14
03/28/2005 (1:56 am)
How to I put an emitter on the user, so instead of the weapon he's holding a light?
#15
11/03/2009 (7:04 pm)
--
#16
11/03/2009 (7:11 pm)
--
Torque Owner Sam3d
function yourTrig::onEnterTrigger(%this, %trigger, %obj)
{
Parent::onEnterTrigger(%this,%trigger,%obj);
makeEmitter();
}
function yourTrig::onLeaveTrigger(%this,%trigger, %obj)
{
Parent::onLeaveTrigger(%this,%trigger,%obj);
StopEmitter();
}
function makeEmitter(){
$anEmitter = new ParticleEmitterNode() { etc };
}
function stopEmitter() {
$anEmitter.delete();
}