View unanswered posts | View active topics It is currently Thu Apr 25, 2024 10:09 am



Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3
 Glowing Laser Beam Trail 
Author Message
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post Re: Glowing Laser Beam Trail
it was a syntax error and it trying to use the other method when oldpos was equal to self.Pos.
anyway, fixed.
Code:
function Create(self)
   self.oldpos = Vector(self.Pos.X, self.Pos.Y)
   self.numberofdivisions = math.random(10,16)
   for i = 1, self.numberofdivisions do
      local particle = CreateMOPixel("SuperLaser Trail Glow", "BOX.rte")
      particle.Pos = self.Pos - ((self.Vel * (TimerMan.DeltaTimeSecs * FrameMan.PPM)) * (i/ (self.numberofdivisions)))
      MovableMan:AddParticle(particle)
   end
   for i = 1, self.numberofdivisions do
      local particle = CreateMOPixel("SuperLaser Trail Glow", "BOX.rte")
      particle.Pos = self.Pos + ((self.Vel * (TimerMan.DeltaTimeSecs * FrameMan.PPM)) * (i/ (self.numberofdivisions)))
     MovableMan:AddParticle(particle)
   end
   local particle = CreateMOPixel("SuperLaser Trail Glow", "BOX.rte")
   particle.Pos = self.Pos
   MovableMan:AddParticle(particle)
end

function Update(self)
   if self.Age > TimerMan.DeltaTimeMS * 1.5 then
      self.numberofdivisions = math.random(10,16)
      for i = 1, self.numberofdivisions do
        local particle = CreateMOPixel("SuperLaser Trail Glow", "BOX.rte")
        particle.Pos = self.Pos - (SceneMan:ShortestDistance(self.Pos,self.oldpos,true) * (i / self.numberofdivisions))
        MovableMan:AddParticle(particle)
      end
   end
   self.oldpos = Vector(self.Pos.X, self.Pos.Y) --set the old position again
end
Keep in mind that this method is flawed in its process, as you'll notice sometimes where the trail hits there will be a line into the terrain. You should essentially be using rays and getting rid of the dependence on particles altogether. But whatever, it'll work. enjoy.


Thu Dec 17, 2009 6:06 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 31 posts ]  Go to page Previous  1, 2, 3

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.604s | 15 Queries | GZIP : Off ]