Data Realms Fan Forums
http://45.55.195.193/

Animating Emitters based on Velocity
http://45.55.195.193/viewtopic.php?f=73&t=17925
Page 1 of 1

Author:  Djinn [ Tue Feb 23, 2010 9:57 pm ]
Post subject:  Animating Emitters based on Velocity

Quick questions: Can you run scripts on dropship engines in the first place? If so, can you have it change animation speed on the engines to match the velocity the engine is currently travelling. No need for trig, straight up checking X velocity would work just fine for my purposes.

Author:  CaveCricket48 [ Tue Feb 23, 2010 10:14 pm ]
Post subject:  Re: Animating Emitters based on Velocity

As of build 23, Lua scripts cannot be run on attachables (including emitters that are attached to objects). You can put the scripts on the parent object, though. The script would be something like this:

Code:
function Create(self)
   self.makeframe = 0;
   self.emitterlist = {};

   for i = 1,MovableMan:GetMOIDCount()-1 do
      attachable = MovableMan:GetMOFromID(i);
    if attachable.PresetName == "AEmitter Name" and attachable.ClassName == "AEmitter" and attachable.RootID == self.RootID then
   self.emitterlist[#self.emitterlist+1] = attachable;
    end
   end

end

function Update(self)

   if self.Vel.Magnitude < 10 then
   self.makeframe = 0;
   elseif self.Vel.Magnitude => 10 and self.Vel.Magnitude < 20 then
   self.makeframe = 1;
   end

   for i = 1, #self.emitterlist do
    if self.emitterlist[i].ID ~= 255 then
   self.emitterlist[i].Frame = self.makeframe;
    end
   end

end


What this does is that it finds AEmitters that are attached it when it is created, and then changes their frame according to the scripted object's velocity. Also, be sure to change the SpriteAnimMode so the emitters can't animate on their own and allow the script to do it.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/