mounting a particle emitter to a weapon
by Jeff Howard · in Torque Game Engine Advanced · 03/21/2009 (6:09 pm) · 3 replies
I've been trying to mount a particle emitter to the tip of a sword. So far, I've successfully implemented the following resource for mounting particle emitters in TGEA 1.8.1.
www.garagegames.com/community/resources/view/14791
Using the engine changes in the resource and the example usage script, I can successfully mount a working particle emitter to the player. However, I haven't been able to mount the emitter to the sword that the player has equipped.
Here is the script that I'm using, following the working example script and changing it for the name of the mounted sword ("SwordImage").
So far, I haven't been able to get a particle emitter to mount to the sword, maybe because of how I am referencing the sword (which is technically an image rather than an object). Does anybody see how I could get the script to work? Any help would be appreciated.
www.garagegames.com/community/resources/view/14791
Using the engine changes in the resource and the example usage script, I can successfully mount a working particle emitter to the player. However, I haven't been able to mount the emitter to the sword that the player has equipped.
Here is the script that I'm using, following the working example script and changing it for the name of the mounted sword ("SwordImage").
new ParticleEmitterNode(){
dataBlock = TorchFireEmitterNode;
emitter = TorchFireEmitter;
mountObject = SwordImage;
mountNode = 0;
};So far, I haven't been able to get a particle emitter to mount to the sword, maybe because of how I am referencing the sword (which is technically an image rather than an object). Does anybody see how I could get the script to work? Any help would be appreciated.
#2
I was trying to do the same thing and I also came across Daniel's resource. As he said the code was designed to work with a simObject and not a dataBlock. So I took a quick look in the code for the shapeBaseImage and found a nice surprise in the comments of the startImageEmitter function:
So apparently the engine is smart enough to handle defining the same emitter on the same node for every state of the weapon, and thereby providing a mechanism for a permanent emitter on any node.
Edit: I just posted a resource detailing how I manipulated the state machine to allow for a permanent weapon emitter to make a flaming sword. (Link)
07/04/2009 (7:56 pm)
Hi Jeff,I was trying to do the same thing and I also came across Daniel's resource. As he said the code was designed to work with a simObject and not a dataBlock. So I took a quick look in the code for the shapeBaseImage and found a nice surprise in the comments of the startImageEmitter function:
// If we are already emitting the same particles from the same // node, then simply extend the time. Otherwise, find an empty // emitter slot, or grab the one with the least amount of time left.
So apparently the engine is smart enough to handle defining the same emitter on the same node for every state of the weapon, and thereby providing a mechanism for a permanent emitter on any node.
Edit: I just posted a resource detailing how I manipulated the state machine to allow for a permanent weapon emitter to make a flaming sword. (Link)
#3
Thanks for the explanation. The mounted particle emitter resource is cool, and I'm sure I will use it in the future.
@Ben:
Thank you for finding that hidden line of code and for linking to your flaming sword resource. That's really helpful!
07/10/2009 (11:56 am)
@Daniel:Thanks for the explanation. The mounted particle emitter resource is cool, and I'm sure I will use it in the future.
@Ben:
Thank you for finding that hidden line of code and for linking to your flaming sword resource. That's really helpful!
Torque Owner Daniel Buckmaster
T3D Steering Committee
When you mount a particle emitter to an object, you need to pass the object's ID number via getID. Currently it's not possible to mount particle emitters to an image - though you could mount the emitter to the same node the weapon is attached to. Mounting on an image would require an additional field in ParticleEmitterNode to give the image slot, then some changes in processTick and interpolateTick would be necessary, to add on the image's node transform.