Game Development Community

Particle effect rotation through script

by Steve D · in Torque Game Builder · 10/30/2009 (1:22 am) · 3 replies

Hi everyone, I read through some docs and forum posts but haven't found a solution. I made a particle effect in the editor and I am mounting it via script using the standard mount command. What I need to do is rotate it, I would prefer to rotate the entire effect or if I have to the particle emitters within the effect. I tried the SetRotation command on the effect object but nothing happens.

Basically I need to modify the Emission Angle Base of the particle emitter through script, anyone have any wisdom for me? Thanks in advance!

#1
10/30/2009 (6:12 am)
All of the following assumes that you really want to modify the Emitter and not the Effect.

If your particle is short lived, you can just do it in the effect. Make sure "Use Effect Emission" is unchecked. Modify "Emittion Angle Base". Set the "Value" fields to your min/max values to rotate through (say, -720 to 720 if you need to circle 4 times). Set the Time max to your duration (say, 10 seconds).

If you actually need to do it in script, it's not too hard. Find out what position the emitter is in your effect's list. If it's the first (or only) one, use the function "getEmitterObject(0)" to get it. If it's the second, the parameter is 1, and so on. Then you need to select your graph with "selectGraph". The parameter will be the value you want to modify. Finally, you use "addDataKey" to set a point in the graph.

If you assume the variable "%pe" is a particle emitter, the following will roughly step you through the process.

%pee = %pe.getEmitterObject( 0 );
%pee.selectGraph( emissionangle_base );
%pee.addDataKey( 0, -720 ); // <time>, <value> pair
%pee.addDataKey( 10, 720 ); // See note below
%pe.playEffect();

If you just want to set it, only do the first data key. The particle effect will be playing (pretend like we're 100 seconds into it already) and will look backwards for the latest data point. If the one at time 0 is changing, the particle will use it.
#2
10/30/2009 (6:54 pm)
Thanks for the answer William, over the next few days I will work on this and let you know what the results are.
#3
11/05/2009 (11:58 am)
William it worked great, thanks for the info!