View unanswered posts | View active topics It is currently Thu Dec 26, 2024 5:36 pm



Reply to topic  [ 67 posts ]  Go to page 1, 2, 3, 4, 5  Next
 Lua trails? 
Author Message
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Lua trails?
So, i'm trying to add a trail to a MOPixel using lua, but, i'm failing. >_____>'

First, I tried directly creating the trail particle
Code:
   local trail = nil;
   trail = CreateMOPixel("trail name");
   trail.Pos.X = self.Pos.X;
   trail.Pos.Y = self.Pos.Y;
   MovableMan:AddParticle(trail);

No trail was seen and it lagged bigtime.

Then I tried attaching an AEmitter to the MOPixel to emit the trail particles
Code:
function Create(self)
   self.trail = CreateAEmitter("trail name","mod.rte");
   self.trail.Pos = Vector(self.Pos.X,self.Pos.Y);
   self.trail.Vel = self.Vel;
   MovableMan:AddParticle(self.trail);
end

function Update(self)
   if MovableMan:IsParticle(self.trail) == true then
      self.trail.Pos = Vector(self.Pos.X,self.Pos.Y);
      self.trail.Vel = self.Vel;
   end
end

Again, no trail was seen but it didn't lag

What am I doing wrong?


Mon Aug 03, 2009 6:32 pm
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Lua trails?
Okay, MaximDude. I actually had this problem, but here's what you would do.

In Create
Code:
self.aemitter = CreateAEmitter("Blah");
self.aemitter.Pos = self.Pos
self.aemitter.Vel = self.Vel
MovableMan:AddParticle(self.aemitter);



In Update.
Code:
self.aemitter.Vel = self.Vel
self.aemitter.Pos = self.Pos


Really should work

Worked for me :3


Mon Aug 03, 2009 7:46 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Still no go...
I suspect that it is me doing something wrong...

My AE was an AddAmmo AE, I changed it to an AddEffect AE, but it still doesn't show...

And my CC becaue really crashy for some reason... >_________>'
I'll have to look into this.

Thanks anyway.


Mon Aug 03, 2009 8:31 pm
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Lua trails?
first of all you are adding it to the exact same place as the original particle, so it may actually be workin but it's just behind the other one, try adding this:

if (self.Vel.X > 0.1) then trail.Pos.X = trail.Pos.X + 1; end
if (self.Vel.X < -0.1) then trail.Pos.X = trail.Pos.X - 1; end
if (self.Vel.Y > 0.1) then trail.Pos.Y = trail.Pos.X + 1; end
if (self.Vel.Y < -0.1) then trail.Pos.Y = trail.Pos.X - 1; end
(note I don't use 0 because it's very unlikely it's ever going to be exactly 0)

Also, adding things to the scene with lua has been problematic with me so yeah, if that doesn't fix it it's a problem with how you are adding it


Mon Aug 03, 2009 8:53 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
robolee wrote:
first of all you are adding it to the exact same place as the original particle, so it may actually be workin but it's just behind the other one, try adding this:


The particle being created has PinStrength, so its supposed to stay behind the particle while it moves forwards.

In the 2nd code, I attached an AEmitter to the particle. Again, particles emitted from it would always stay behind.

Quote:
Also, adding things to the scene with lua has been problematic with me so yeah, if that doesn't fix it it's a problem with how you are adding it


It most likely is.

Emitters should be able to be attached to MOPixels. I see no reason why not.
It would make the proces of pretty glow trail creation alot easier.

I wonder if I can add sharpness to an AE... Then i'd use it directly.


Mon Aug 03, 2009 9:05 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
I, am a ♥♥♥♥ idiot.
All this time, the LifeTime on the glow particle was set to 10... It was meant to be 1000....
Everything worked just fine from the very beginning... I just couldn't see the result...

/doublefacepalm

Thread can be closed now. :roll:


Mon Aug 03, 2009 9:37 pm
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Lua trails?
I see it's just that you were adding the velocity of the particle to the trail particle and in update you were updating the position of the trail particle to match with the leading particle, and I thought you were after some kind of trail flowing behind it rather than a static trail. You usually find the problem lies within the annoying little things like that :P


Mon Aug 03, 2009 9:53 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
robolee wrote:
I thought you were after some kind of trail flowing behind it rather than a static trail. You usually find the problem lies within the annoying little things like that :P


Actually, I am trying to do that.
A nice glowy trail behind it, but, it doesn't quite work because of the particle's speed is too high. So its just blobs at equal intervals.


Mon Aug 03, 2009 10:14 pm
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Lua trails?
Uh can I see the glows and um aemitter's code? Just the part where it is emitting the glow and the whole glow code. :3


Mon Aug 03, 2009 10:17 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Mind wrote:
Uh can I see the glows and um aemitter's code? Just the part where it is emitting the glow and the whole glow code. :3


Why would you need that?
Its a regular MOPixel with ScreenEffect and an AddEffect AEmitter emitting that pixel.
The script is attached to a round.


Tue Aug 04, 2009 3:37 pm
Profile
User avatar

Joined: Fri Oct 17, 2008 9:46 pm
Posts: 5212
Location: The Grills Locker.
Reply with quote
Post Re: Lua trails?
Well, how about this:

Code:
function Create(self)
   self.timer = Timer();
   trail = CreateMOPixel("Plasma Cutter Trail","Apollocalipse.rte");
   
end


function Update(self)


   if self.timer:IsPastSimMS(10) == true then
      self.timer:Reset();   
      trail = CreateMOPixel("Plasma Cutter Trail","Apollocalipse.rte");
      trail.Pos = self.Pos;            
      MovableMan:AddParticle(trail);
   end      
end


It's what I used for a laser gun I made yesterday. Doesn't lag at all. Here's the effect it creates:


Attachments:
File comment: The effect.
lasergun.png
lasergun.png [ 179.65 KiB | Viewed 4964 times ]
Tue Aug 04, 2009 10:14 pm
Profile WWW
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
My code works too, and the result is the same.
Though, I wanted it to be more like •••••• then • • • • • •, but that really depends on the speed of the round.


Wed Aug 05, 2009 3:31 am
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Lua trails?
And how short you make the timer.


Wed Aug 05, 2009 5:06 am
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Mind wrote:
And how short you make the timer.


0/1 sim MS.
And still, • • • • • • and not ••••••••.


Wed Aug 05, 2009 2:40 pm
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Lua trails?
How fast are you shooting the bullet?


Wed Aug 05, 2009 9:51 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 67 posts ]  Go to page 1, 2, 3, 4, 5  Next

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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.067s | 15 Queries | GZIP : Off ]