Data Realms Fan Forums
http://45.55.195.193/

Aerodynamic Lift
http://45.55.195.193/viewtopic.php?f=73&t=14837
Page 1 of 1

Author:  Darlos9D [ Thu May 21, 2009 5:30 pm ]
Post subject:  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.

Author:  Grif [ Thu May 21, 2009 11:38 pm ]
Post subject:  Re: Aerodynamic Lift

Neat little code snippet there.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/