Hi, I have a probably rookie question.
I am trying to simulate simplified lift. I have calculated the force and am trying to apply it in a direction. This direction should be perpendicular to the velocity and in the up direction of the wing.
I have tried but I just can’t grasp vectors that well, I would love to know how you would do it or a good way to visualize/better understand vectors and quaternions
Well, lift is generated by the shape of the wing, so the direction of the lift would actually be upwards relative to the aircraft. Though the amount of lift depends on the angle of attack relative to the airflow. It’s not clear if you already account for that. If you don’t, the usual solution is to convert the effective airspeed (so if you simulate wind, you would add the wind and VOC to get the effective air speed) into local space and you only care about the part in the z direction since that’s usually the part that is relevant for the lift.
Though if you already account for the angle of attack, you can calculate the lift by taking the vector cross product between your velocity vector and the worldspace “right” vector of your aircraft (transform.right). This gives you a vector perpendicular to those two directions and should point upwards when the aircraft moves forwards.
As you may know, lift is actually produced due to a pressure difference between the top and bottom side of the wing. The airflow over the top has to travel a longer distance compared to the airflow underneath. This creates a lower pressure on the top side. This is called Bernoulli’s principle. Mechanically it’s irrelevant in which direction the aircraft moves. If it flies straight upwards, the lift would still be along the “local up” direction and push the aircraft sideways. In order to get a more realistic flight mechanic, you probably need a lot of variables. Especially proper drag and a proper drag coefficient
Don’t forget the torque!!! Lift, drag and torque are the primary forces acting on an airfoil.
That said… holy berries, guys, I have found the freakin’ COOLEST little Unity aircraft physics package EVARRR… as a complete and total aviation nerd myself, I about dropped my tip tanks and jumped clear out of my fuselage when I ran across this one.
Check it:
https://github.com/kurtdekker/Aircraft-Physics
This is the discussion video:
https://www.youtube.com/watch?v=p3jDJ9FtTyM
This guy mucked with it too:
https://www.youtube.com/watch?v=e91QA4WfL5Q
I’ve got it running in my Pilot Kurt game, at:
Appstore: https://apps.apple.com/us/app/pilot-kurt/id1153921946
GooglePlay: https://play.google.com/store/apps/details?id=com.plbm.flight1
It plays FANTASTICALLY, plenty performant even on min spec 10-yr-old mobile hardware.
I already calculate a float with the lift equation, and i approximate the lift coefficient with angle of attack and a linear part and a parabolic drop-off when the angle is too high. But is the worldspace right of the aircraft always right? Even if sideways or upside down? Thank you very much for your awnser
Yes, transform.right is the red arrow of your object in worldspace. So if the plane is banked 90° to the right, the red arrow would point downwards.
transform.right is literally public Vector3 right => rotation * Vector3.right;
So the answer is yes. It’s just a convenience getter.
Thank you very much, this worked!