View unanswered posts | View active topics It is currently Fri Dec 27, 2024 9:37 am



Reply to topic  [ 67 posts ]  Go to page Previous  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 Re: Lua trails?
Mind wrote:
How fast are you shooting the bullet?


Something around 100, maybe 110.


Wed Aug 05, 2009 10:21 pm
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Lua trails?
in the create script:
lastposx = self.Pos.X; lastposy = self.Pos.Y;
counter = 0;

in the update script:
dist = self.Pos.Magnitude - (lastposx,lastposy).Magnitude;
angle = math.atan(self.Pos.X-lastposx,self.Pos.Y-lastposy);
spread = dist / 4; --for 4 particle trail in between each position
while (counter < 4) do --for 4 particle trail in between each position
counter = counter + 1;
trail = CreateMOPixel("yourparticle");
trail.Pos.X = lastposx + (counter * (math.cos(angle)*spread)); --last pos + (iteration * hypotinuse)
trail.Pos.Y = lastposy + (counter * (math.sin(angle)*spread));
MovableMan:AddParticle(trail);
end
if (counter == 10) then counter = 0; end

--anything else you want to add

lastposx = self.Pos.X; lastposy = self.Pos.Y;

I believe that's what you want good sir. instead of having one particle emitted you know have 4 particles (or more if you increase the number, though I think it may get a little laggy if make it too high).


Thu Aug 06, 2009 3:32 am
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Having an issue with line 8: 'dist = self.Pos.Magnitude - (lastposx,lastposy).Magnitude;'
Console says '(' is expected near ','.

So I changed it to: 'dist = self.Pos.Magnitude - (lastposx),(lastposy).Magnitude;'
Now it says 'Attempt to index global 'lastposy' (a number value)'

Wut? :???:


Fri Aug 07, 2009 9:19 am
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Lua trails?
Do this: lastpos = Vector(self.Pos) in create

and then to reference X and Y use:
lastpos.X and lastpos.Y


Fri Aug 07, 2009 2:38 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Goddamnit, CC is ♥♥♥♥ stupid.

I changed it to what you said, then there was some BS about 'lastpos' being a nil value.
So I changed it to 'lastpos = Vector(self.Pos.X,self.Pos.Y)' and the other part to '(lastpos.Pos.X),(lastpos.Pos.Y)' and now there is some BS about 'Pos' being a nil value.

What the ♥♥♥♥!?

/semi-rage


Fri Aug 07, 2009 3:10 pm
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Lua trails?
Code:

function Create(self)
lastpos = Vector(self.Pos.X, self.Pos.Y);

function Update(self)
dist = self.Pos.Magnitude - lastpos.Magnitude;


Try that

Your problem is when you had lastpos.Pos, that was messing it up.


Fri Aug 07, 2009 6:10 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Mind wrote:
Code:

function Create(self)
lastpos = Vector(self.Pos.X, self.Pos.Y);

function Update(self)
dist = self.Pos.Magnitude - lastpos.Magnitude;


Try that

Your problem is when you had lastpos.Pos, that was messing it up.


Now the problem is with .Pos in the next line...
Screw this, i'll go through it later.


Fri Aug 07, 2009 6:39 pm
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Lua trails?
n the create script:
lastposx = self.Pos.X; lastposy = self.Pos.Y;
lastpos = Vector(lastposx,lastposy);
counter = 0;

in the update script:
dist = self.Pos.Magnitude - lastpos.Magnitude;
angle = math.atan((self.Pos.X-lastposx), (self.Pos.Y-lastposy));
spread = dist / 4;
while (counter < 4) do
counter = counter + 1;
trail = CreateMOPixel("yourparticle");
trail.Pos.X = lastposx + (counter * (math.cos(angle)*spread));
trail.Pos.Y = lastposy + (counter * (math.sin(angle)*spread));
MovableMan:AddParticle(trail);
end
if (counter == 10) then counter = 0; end

--anything else you want to add

lastposx = self.Pos.X; lastposy = self.Pos.Y;
lastpos = Vector(lastposx,lastposy);

I wasn't sure about using magnitude on (x,y).Magnitude when I put that up, so it seems that doesn't work, however the above should ;)


Fri Aug 07, 2009 7:24 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Well, it works now, but I don't see how it's different from what I used before...

This is what i'm after:
Image
The only way to achieve this effect is having the particle travelling at 20-40 px/ms, no more then that.

This is what i'm getting:
Image

Shame you can't directly apply a glow to a particle's trail.


Fri Aug 07, 2009 8:03 pm
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Lua trails?
spread = dist / 4;
while (counter < 4) do

change the 4's to whatever you want, however the more you the laggy it may get

spread = dist / 10;
while (counter < 10) do


Fri Aug 07, 2009 8:20 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Image

That doesn't look quite right... >_________>'
The particles don't really expand like that while not pressing PS, so the first few shots are how it looks like in real-time, but they always stay upright, so that is an issue...

Oh yeah, and the glow particles travel through terrain as well... >__________>'


Fri Aug 07, 2009 8:31 pm
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post Re: Lua trails?
I mean really just attach an aemitter that emits a lot of glow particles. Much easier than any of this. Also, you can only have it emit so often, so if the aemitter emitting 10000 particles per minute does nothing, then you'll be stuck with that.


Fri Aug 07, 2009 10:32 pm
Profile
User avatar

Joined: Wed Nov 22, 2006 3:19 pm
Posts: 2073
Reply with quote
Post Re: Lua trails?
Mind wrote:
I mean really just attach an aemitter that emits a lot of glow particles. Much easier than any of this. Also, you can only have it emit so often, so if the aemitter emitting 10000 particles per minute does nothing, then you'll be stuck with that.


An emitter doesn't emit in intervals smaller then 1ms. 10k, 36k, over9000k particles - Doesn't make any difference.
You will always get this no matter how many particles it will emit.
Image

With this it looks and works like I need it to, except it stays upright... That needs fixing...


Fri Aug 07, 2009 10:36 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Lua trails?
Updating once per sim with three particles, using a little basic trig on vel to find the other sets of particles, should be all you need (none of this insane ♥♥♥♥ RL's doing)


Sat Aug 08, 2009 12:06 am
Profile
User avatar

Joined: Fri May 11, 2007 4:30 pm
Posts: 1040
Location: England
Reply with quote
Post Re: Lua trails?
robolee wrote:
angle = math.atan((self.Pos.X-lastposx), (self.Pos.Y-lastposy));


DUH! oh god, big fail on my part... (I'm surprised it wasn't spotted by the rest of the community) that comma should be a divide... how was it even working with that? Also it would be better to use the velocity instead of doing sums of the positions:

angle = math.atan(self.Vel.X/self.Vel.Y);

edit: also this line:
if (counter == 10) then counter = 0; end
the number ten should be the same as the number of particles you want (they were all originally ten, when I changed the first two instances I forgot to change that line)


Sat Aug 08, 2009 2:57 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 67 posts ]  Go to page Previous  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.069s | 14 Queries | GZIP : Off ]