Aircraft Realistic Physics (Airfoils)

Hello.

Recently I was working on a physics system for airplanes, and after a lot of research I ended up thinking that simulating physics in the airplane’s components, individually, would be more realistic.
At the moment, I haven’t made much progress in one specific part: The lift coefficient.

During some mental experiments I was doing, I couldn’t really come up with a solution to the problem I’m having now, I believe it’s more due to the burnout I had with airplane physics (and aerodynamic studies), which I redid several times until I reached a result now (which I’m doing calmly, step by step). And until then the initial result was good, since drag worked and that was a mini-progress.

If you have solutions or can help me with this, that would be more than great.
I had watched several videos, in addition to one specific video that was a unity tutorial, I translated all the cs code to luau, and I got an almost ok result, but it was extremely imprecise (because the problem was the coefficient of lift still, and the plane could never do the pitch, yaw, roll effect), but I actually did it because I couldn’t think of anything anymore.
None of the videos so far were able to help me, since the problem was in the lift coefficient, perhaps the angle of attack was the problem? I don’t know exactly what values ​​it should return, and the idea, or concept, I already understood more than completely, but the problem was really just applying it to make something more precise, since I was thinking steps ahead to also have a stall effect for the plane.

In fact, it would be good for me to use the dot product, but I actually had more of this problem of wanting to make things realistic, and I had a certain prejudice with it. Until I can just understand the problem, and fix it, that alone would be great, maybe I could get an idea of ​​the rest of the things to make the simulation better.

This is how the airfoil code looks like now:

function Airfoil:CalculateState(): ()
	local Airfoil			= self.Airfoil
	
	local LinearVelocity	= Airfoil.AssemblyLinearVelocity
	local AngularVelocity	= Airfoil.AssemblyAngularVelocity
	
	if LinearVelocity.Magnitude <= 1e-4 then
		LinearVelocity		= Vector3.one * 1e-4
	end
	
	local LocalVelocity		= Airfoil.CFrame:VectorToObjectSpace(LinearVelocity)
	local LocalAngular		= Airfoil.CFrame:VectorToObjectSpace(AngularVelocity)
	
	self.LinearVelocity		= LinearVelocity
	self.AngularVelocity	= AngularVelocity
	
	self.LocalVelocity		= LocalVelocity
	self.LocalAngularVelocity	= LocalAngular
end

function Airfoil:CalculateAngleOfAttack(): number
	local LocalVelocity		= self.LocalVelocity
	return -math.atan2(LocalVelocity.Y, -LocalVelocity.Z)
end

function Airfoil:CalculateLiftCoefficient(AngleOfAttack: number): number
	local CL0 = 0
	local CLA = 2 * math.pi
	local CL = CL0 + CLA * AngleOfAttack

	if (AngleOfAttack > math.rad(15) or AngleOfAttack < math.rad(-15)) then
		CL = CL * 0.5
	end

	return CL
end

function Airfoil:CalculateDragCoefficient(Lift: number): number
	return 0.1 + (Lift^2) / (math.pi * 1.5 * 0.7)
end

--[[ Public Methods ]]--
function Airfoil:Update(DeltaTime: number): ()
	self:CalculateState()
	
	local VectorForce		= self:GetForce('Physics')	:: VectorForce
	
	local Airfoil			= self.Airfoil
		
	local LocalVelocity		= self.LocalVelocity
	local LinearVelocity	= self.LinearVelocity
	
	local DynamicPressure	= 0.5 * Utilities.AirDensity * LocalVelocity.Magnitude^2
	
	local AngleOfAttack		= self:CalculateAngleOfAttack()
		
	local LiftCoefficient	= self:CalculateLiftCoefficient(AngleOfAttack)
	local DragCoefficient	= self:CalculateDragCoefficient(LiftCoefficient)
		
	local LiftDirection		= Airfoil.CFrame.UpVector
	local LiftForce			= LiftDirection * DynamicPressure * LiftCoefficient
	
	local DragDirection		= -LinearVelocity.Unit
	local DragForce			= DragDirection * DynamicPressure * DragCoefficient
	
	local TotalForce		= DragForce + LiftForce
	
	VectorForce.Force		= Airfoil.CFrame:VectorToObjectSpace(TotalForce)
end

This is how it looks like now:

The goal I want to achieve: Watch goal (expecting without the problem) | Streamable
I believe I’m not too far away to achieve this, but yeah, I’m stuck at the moment.

2 Likes

have you tried putting a slight force (upwards or downwards depending on rear flaps idk) near the propeller?

I don’t think it would make much difference, since the problem is more in the lift as I said. The plane’s elevators are more so that it can at least go up, and I only applied this to them since I wanted to see if the plane would at least “rotate” up or down (pitch), which would be good, but it’s not very accurate currently. Now, if this works, I will apply it to the plane’s flaps, and I think they will already be able to provide good lift in that area (so that it won’t make the plane’s nose fall), but I had tried already (and it actually remained the same thing, very “broken”).

Your trying to replicate the behavior you see in wing of glory. That game is goated. The main problem here is that wings of glory doesn’t simulate individual components like you do, and it considers the plane more as a single object, using body movers to simulate the feel of actual physics. What your doing here is definitely more realistic in theory, and likely in application, but its not scalable unless this is a one off thing. If you want to continue with this specific implementation, you should watch Suphi Kaner’s video where he does something very similar to this that might help you. However, if your looking for something more simple and your willing to compromise, I shared a breakdown of realistic flight physics with an example you can use. Its got AOA calculations, thrust, lift, and drag and everything. I spent a few hundred hours over about half a year to make a project similar to this. It really is suffering, but i hope you can benefit it: Creating Realistic Plane Physics

1 Like

Thank you, I’ve watched Suphi’s video and got some ideas from it, the problem is that I couldn’t really get a base on what to do about the calculations, since this made me doubt whether or not I should continue using them, since in those Unity tutorials, they used the same calculations, and for me it didn’t make much sense, since I was in this duality of doing my own workarounds or simply continuing with the calculations now and praying that someone experienced comes and can help me with what I’m doing wrong.

I believe this is one of the most challenging systems I’ve ever made, really, anyone who can make a system like this in perfect condition is a genius. (This is what I was underestimating, thinking it was something easy, but I’ll keep trying so maybe I can learn from it.)

I had thought about using the Dot Product for the angle of attack, but of course I doubted it, because in the videos they show “math.atan2(LocalVelocity.Y, -LocalVelocity.Z)”, so what? I had actually chosen much more to leave at least part of the plane’s physics in a cool way, something almost realistic, or something that could give that feeling. At least something close to War Thunder (maybe 1%, shouldn’t be too much and looks “reachable”).

But, yeah, I think something annoying that I’m facing is precisely in this part of the speed each component of the plane, because for some reason, it becomes very high or something more or less like that happens.

I had seen some videos of how things in this part work, but I think what made me understand less was the application (which was what I was worried about), while the theoretical part I had in mind, but that slowly disappears if I can’t apply it to something, or am unable to figure out how to apply it, which leaves me a little disappointed.

Furthermore, at the same time, even though I had the knife and butter in my hand, some things were a little imprecise regarding the force that is applied. Since I didn’t know what values ​​would be good for things to work the way they should. For example, in lift, I printed it and doubted whether the value that varied should really print something like 1.3, 1.4, 0.6, -1.2, of course it was a pattern and it depended a lot on the angle of attack, but you must have understood, I had no idea what I was doing, and I was just replicating what others did without knowing exactly how each thing should act, even though I had the concept of how things worked in mind, and yes, I’m someone very literal. in this part. (It’s like knowing everything about drifting and never having tried it.)

I took a look at your post and I’m very impressed, it really will help me a lot and I thank you immensely for what you did. Not everyone does something like this, as they usually decide to “gatekeep”, which is understandable, but which could make some people understand what they are doing wrong, at least learn from it, like I’m doing.

1 Like