View unanswered posts | View active topics It is currently Sat Apr 27, 2024 12:23 pm



Reply to topic  [ 2 posts ] 
 Aerodynamic Lift 
Author Message
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Aerodynamic Lift
Code:
function Create(self)
   self.liftMultiplier = 0.01;
   self.liftMaximum = 0.35;
end

function Update(self)
   local lift = math.abs(self.Vel.X) * self.liftMultiplier;
   if lift > self.liftMaximum then
      lift = self.liftMaximum;
   end
   self.Vel.Y = self.Vel.Y - lift;
end

Here's some code I came up with. My aim was to create a "lift" effect similar to what wings might actually produce were they designed properly for whatever they're attached to, because I'm not a big fan of the "GlobalAccScalar" for things that are supposed to actually fly through aerodynamics. Basically, it just applies an upward force (in relation to the world, not the object) proportional to the object's current X velocity, and the force is capped at a certain amount so the object doesn't overpower the downward force of gravity too much. Really, this script here should work perfectly for a flying object of any mass. This is because of the two assumptions inherent in it: first, that the wings are big enough and designed properly to generate the necessary upward force to keep such a mass aloft, and secondly that the wings are designed to adjust themselves properly to always produce an upwards force in relation to the world, regardless of the object's actual angle. Since these are the major attributes of actual well-designed wings (as far as I know), this code should be universal. The result is a very nice trajectory on things like rockets, where they keep flying fairly straight a good while even after their thrusters burn out, since they still maintain enough X velocity to keep up a good lift. Be sure to add in some AirResistance to the object though, or it'll just fly forever.


Thu May 21, 2009 5:30 pm
Profile YIM
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: Aerodynamic Lift
Neat little code snippet there.


Thu May 21, 2009 11:38 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.257s | 15 Queries | GZIP : Off ]