View unanswered posts | View active topics It is currently Wed Jul 03, 2024 7:37 am



Reply to topic  [ 7 posts ] 
 Negative Air Friction 
Author Message
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Negative Air Friction
Code:
function Create(self)
   self.acceltimer = Timer();

   self.acceldelay = 100; -- time-delay between accelerations (in MS).
   self.acceleration = 2; -- scalar acceleration. 1 is no acceleration, 0.5 is deceleration by half previous vel, 2 is acceleration by double previous vel.
end

function Update(self)
   if self.acceltimer:IsPastSimMS(self.acceldelay) then
      self.Vel = Vector(self.Vel.X,self.Vel.Y)
   end
end

There's your acceleration/deceleration script.


Tue Jun 22, 2010 1:38 am
Profile
User avatar

Joined: Sat Jun 19, 2010 5:02 pm
Posts: 331
Location: Mekkan
Reply with quote
Post Re: Negative Air Friction
In your script, where does it multiply the velocity by the acceleration? It looks to me like the update method isn't changing the velocity of whatever the script is attached to at all.


Wed Jun 23, 2010 3:03 am
Profile
User avatar

Joined: Wed Jan 07, 2009 10:26 am
Posts: 4074
Location: That quaint little British colony down south
Reply with quote
Post Re: Negative Air Friction
Change
Code:
      self.Vel = Vector(self.Vel.X,self.Vel.Y)
To
Code:
      self.Vel = Vector(self.Vel.X* self.acceleration,self.Vel.Y*self.acceleration)
Maybe?


Wed Jun 23, 2010 6:02 am
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Negative Air Friction
Whoops, forgot to put that in. What 411570N3 said.


Wed Jun 23, 2010 7:47 am
Profile
User avatar

Joined: Sun Apr 25, 2010 12:04 am
Posts: 303
Location: Australia
Reply with quote
Post Re: Negative Air Friction
Yes all very well, and well done, but do you attach it to the bullet or the weapon?


Code:
AddEffect = MOPixel
   PresetName = *Bullet*
   ScriptPath = ???????/????.lua

Or
Code:
AddDevice = HDFirearm
   PresetName = *Weapon*
   ScriptPath = ???????/????.lua


Oops, it is a slightly old thread. Hope you don't mind.


Sun Jul 04, 2010 5:51 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13143
Location: Here
Reply with quote
Post Re: Negative Air Friction
You attach the script to the object that you're trying to deccelerate.


Sun Jul 04, 2010 6:05 am
Profile
User avatar

Joined: Sun Apr 25, 2010 12:04 am
Posts: 303
Location: Australia
Reply with quote
Post Re: Negative Air Friction
Soo.. The bullet.


Yeah i'll test this in a bit.


Sun Jul 04, 2010 6:09 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

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.039s | 13 Queries | GZIP : Off ]