Page 1 of 1

Directional SFX

Posted: 09 Apr 2014, 14:37
by Emyfour
Hi there.
Now thanks to your help I'm understanding LUA better, and, obiouvsly, I overstimated my ability and projected something enormous.
Now, I'm managing to find what I need on the wiki, but I didn't find a thing: is it possible, in the animation script, to tell a unit to emit something (smoke, flame etc) directionally, non-radially?

I can't explain myself, I'll give an example: I'm creating a fighter unit and I'd like an afterburner animation if the speed is major than a value. But, if I just use the EmitSfx function, the flame I designed comes out randomly from the engine piece, as it was burning.

Thanx in advance for your help :-)

Re: Directional SFX

Posted: 09 Apr 2014, 18:06
by FLOZi
For afterburners, LUPS is the best bet, visually.

If you want to stick with CEG, we'll need some more details. BitmapMuzzleflame is often used for engine flare effects and is directional, you may need to rotate the piece in the script first to ensure it points in the right direction (Generally speaking it is better to EmitSfx from a blank piece which contains no mesh geometry).

Re: Directional SFX

Posted: 09 Apr 2014, 20:24
by Beherith
There are few things about emitting directional cegs with emit-sfx from unit scripts:
If the piece has no geometry, then the sfx is emitted in the +z direction from the origin of the piece.

If the piece has 1 vertex, the emit dir is the vector from the origin to the the position of the first vertex the emit position is the origin of the piece.

If there is more than one vertex in the piece, then the emit vector is the vector pointing from v[0] to v[1], and the emit position is v[0].

Thus it is not common to emit directional effects from pieces with geometry. The standard practice is to create empty pieces and rotate them to the desired direction in the script's Create() method, and use those for emitting.

Added this info to the wiki;
http://springrts.com/wiki/Animation-LuaCallouts#Effects
http://springrts.com/wiki/Animation-CobConstants

Re: Directional SFX

Posted: 11 Apr 2014, 22:32
by Emyfour
Thanks Beherit, I knew I could count on your help.

Oh by the way, I found a topic somewhere about scripting, it said that there were no pages on the wiki about the SFX. It could be changed now, if I remember well, it was something like "stumpy tutorial" and "polishing the stumpy".

Thanks again and GL everyone :lol: :lol: :lol:

EDIT: Ah-ehm, I think a tip would be useful, something like "to get a non-dimensional object to emit SFX from, the simplest way is to add an empty with Upspring in the point you'd like the origin of the effect to be".