I'm amazed and saddened by the lack of views and comments on this video. Love them all, very well thought out and clearly researched and understood before implementation. Keep up the good work!
Man, this is super cool! I never thought about the unrealistic physics in other video games, and I respect the time and effort you've taken to create this passion project Definitely looking forward to your next upload!
your passion burns throughout the whole video. Im making a mech game that involves air combat(might extend to space battles) and fighter jet target systems and your in depth explaination really helps me understand more about the essence these games strive to recreate, thank you and subscribed.
17:06 The reason you use the cross product is because the g vector is perpendicular to both the velocity vector of the aircraft and the rotation vector of the turn that craft is making. Due to the fact that the rotation vector is always perpendicular to the velocity vector in most maneuvers, the magnitude of the g load is equal to the product of the magnitudes of the velocity and rotation vectors, hence why the math works out like that. I hope that makes sense
I;m amazed by the amount of effort you put in the presentation to explain the physics in detail, which non other video on UA-cam about flight physics for game dev has done. Great job. You deserve a lot more sub and view
Wow... I was just looking for a cool HUD for a learning project I am doing... Ended up getting a class in flight physics... Amazing work and even more amazing you shared it all with everyone. Thank you
One thing Ive been looking in flight sims is the feature to create dynamic campaigns. Sure having a good model is the main thing but what you need it for is also important
THIS IS WHAT I NEED, a More Realistic Physics, Ace Combat, people think doing Cobras on AC is fun but doing a Cobra in a more realistic game is satisfiying as fuck
Firstly, absolutely great tutorial. Love it. I've calculated drag in the full formula way. It's easy, because you have several of those numbers as constants, so you can precalculate them (I did it on the paper, basically) and you'll have realistic calculation in the end. (the part of it is the drag area which has findable values of say 0.3 times the area, which you can calculate per axis). You can use real engine force, real drag coefficients, real lift values of a given plane and it will fly comparably... (as in, it's not a sim, but it kinda acts like one). My jet could achieve the real max speeds, climbs etc. with an error of a few percents without me tweaking anything. You are going the hand tweak route, which will need much more tweaking as compared to tweaking the "real" values a bit (from my experience).
Seeing your rotations - I was simulating it more realistically and then I've implemented Fly By Wire on top of it (player rolls, plane also pitches, so FBW compensates the pitch). You could try that, it was a fun thing to try to implement and I've personally enjoyed the end result, where the plane can be twitchy and self correcting. It was what made it feel "physical".
This is one of the best approachings to putting together flight in unity. It's still slightly too realistic - at first - but it's an awesome way to build gameplay around flying skills. I've been playing with this for a few days now - I ran into a weird bug I cannot trace the source off. After a couple of seconds or more, I lose all lift in all surfaces - with gizmos visible I can see them just getting smaller fast and disappearing. I use the stock airfoils with reduced lift and drag for (75 and 35 respectively). This can be a very successful asset store template with minimal additions: 1) multiple targets, 2) rotor planes (biplane and mono) 3) slightly more arcade controls 4) sound support. I would be more than happy to provide whatever art you need to help you put this up on the asset store (or just upgrade the git project). edit - resetting the collision box on the plane to its original scale/values solved the problem.
This is one of the best resources - however, after following the tutorial and spending hours looking through the source code, I cannot figure out how the inputs are actually called. I understand you're using the new unity input system, however, the two primary scripts "Plane" and "PlayerController" seem to never actually reference the function "OnRollPitchInput" or "SetThrottleInput" - am I missing something?
AceCombat and Project Wingman both have more involved physics than what you have shown here. They just have the weapons and AI configured to make it easy, but energy, stall, induced drag - they have all of that. I loved to play around the time of AC3-ACX and you could absolutely ignore tactics but if you do consider your mission target, the aircraft you have, its configuration and loadout and fly according it makes a big difference. Some aircrafts there had abysmal low speed acceleration and high induced drag for yaw. So if you keep some height, don't turn too hard and stay at cruise speed the aircraft feels a lot more nible and getting a solid lockon becomes way easier.
I kinda wanna make all the forces apply at the appropriate positions instead of always at center of mass, the program a flight stability assist computer and this can be damaged by bullets or electrical failure
Just found this series. Looks amazing! Can I program it to work with a keyboard and a mouse (like war thunder for example)? I don't have a lot of coding experience(only scratch), how hard will programing it like this be? Is there any chance you will make a short video about it?😬 Thanks!
Great video. The result is stunning!! I have one little question. The definition angle of attack wouldnt be the angular difference between the velocity and the nose of the plane, instead of the angle between y and z components of velocity right away??
Sheeesh, nice video man! Learned a lot from this, btw I have a question.. At low speeds the aircraft tends to preserve momentum from it's previous direction when turning, how do I prevent this from happening? I just can't seem to figure it out
That's intended behavior. At low speeds, the plane creates less lift, so when you turn, the velocity will take more time to align with the new direction you're facing
Ah you don't know about the beloved flight sim series back in the days of DOS and win 98, the Jane's combat simulations series like USAF or Fighters anthology.
Really great video, makes me want to whip out an old compute shader I wrote that uses a low resolution transparent normal render (rendered from the current ortho perspective of the wind) for calculating the per pixel forces and torques. I decided I ultimately needed someone who really knew their planes and shit to have it match a traditionally aggregate simulated formula. Thoughts?
Im having the problem that I was going to change the input to mouse and keyboard, and I changed it all in the "PlayerInput", but it does not work, I tried to debug it but nothings working. Is it using a different input system? help.
What kind of settings are needed to have slow, realistic turning for scissors etc AND cobras and kvochur bell maneuvers? Edit: It seems the G limiter is what prevents a cobra maneuver, for which you need to get 90 AoA and keep altitude almost the same. Let's say G pitch limit is 10. The maneuver can't happen, you just turn upwards, seems to be the case at all speeds. But if the g limit was let's say 20, the Gs pulled in the cobra don't even reach 10. It's just that if the limit was 10 it wouldn't be allowed. Does that make sense?
Would love to hear your thoughts on a 2D-game that re-creates a cockpit screen. For example, in the game DCS:AH-64D there is a weapons MPD (multi-purpose-display) where you can select missiles and code them for the target. The game would take user-input, update the screen, and issue a sound. Would Unity be the preferred tool?
When turning, shouldn't the nose of the craft experience a force pushing it back towards the direction of movement? Currently it seems as if when I nose up and then let off the controls, the nose "sticks" where I left it, whereas it seems as if other flight games model how air resistance exerts a force on the plane so that it turns back in the direction it is headed. I'm probably not explaining it super well, but I was wondering how to implement this in my own project.
You're right, there should be a force like that. That's the stability force that real planes experience. A simple way to model it is by applying a torque that multiplies with AOA. I did not include it in my simulation for simplicity. The way the plane behaves is like a plane with neutral stability (holds nose attitude). A more realistic behavior would be to have positive stability (nose pulled towards velocity vector).
Great Video! I think you could maybe have shortend the implimentation and formular derivation part. Since it think most of it is straight forward. Thanks for the nice project. I'm interested where it's headed :)
Could this be expanded to a space sim kinda game? Having a seamless transition from space to atmosfere fligh, like kerbal or a more realistic star citizen? Or would this solution feel too arcady for a more simulation like game?
Hey man quick question, why did you multiply the local velocity on the y axis by negative one while calculating the angle of attack? Great work by the way!
I wanted AngleOfAttack to be positive when the nose direction is "above" the velocity direction. If I just used the velocity.y component directly, the AOA would be opposite of what I wanted. This problem could also be solved by pulling the negative outside of the function ( -Mathf.Atan2(...) ). Basically, the math behind Atan2 would make the value negative, so I need to multiply by -1 somewhere
One downside though, I seem to be able to go straight up, and after around 3 minutes of climbing I'm still going at 85% of my max speed and it's not going any lower In reality you could not climb completely vertically for an infinite amount of time, you would lose a lot of velocity very fast
I'm trying to follow along, but I can't figure out how to implement inputs for the throttle, which makes it impossible to test if the thrust and inertia stuff is working. What part of the github repository should I be looking in?
Ive tried making my own jet and i copy the code and do what it said and theres a bunch of error messages, i think it needs a bunch of floats added to make it work but i still dont know what to add where. please could you make a follow up video walking us through every process
I'm surprised you hand-tuned the coefficient of drag curve with AoA. It seems like it would be easier and more realistic to estimate the cross-sectional area of the plane with AoA (say, linearly interpolate between the nose-om area and the belly-on area) then you would just have to tune a single scalar and the dependence of AoA should be very realistic without any more calculations than you're already doing.
The coefficient of drag uses an animation curve based on air speed. The Scale6 function does sort of blend between nose-on drag and belly-on drag. However it specifies the drag coefficient directly instead of calculating based on area. The game designer could do those calculations offline and simply plug in the numbers.
The Scale6 function is a really nice idea, I can see myself using it for other things too :) *For those whose plane refuses to leave the ground:* My plane refused to get off the ground since aoa = 0 hence CL = 0 and lift = 0, so I had to add an angle of incidence (set by user in degrees, converted to radians) to the angle of attack, this will also make the simulation more realistic since most planes have their wings rotated slightly backwards This is a really nice video explaining angle of incidence: ua-cam.com/video/AUmL8mIUxyc/v-deo.html
The Utilities class is defined in Utilities.cs in the Github repo. It contains some math functions that are fairly simple and used in multiple places in the code.
I'm amazed and saddened by the lack of views and comments on this video. Love them all, very well thought out and clearly researched and understood before implementation. Keep up the good work!
Guy has 3k subs, the video was barely an hour old when you commented. Stop being so dramatic
Then share this video on your social media.
bad intro lol
Hey. Here we are a year later, and I’m an indie dev, learning about the physics of planes to make a simple iPhone game.
You call me nerdy for playing dcs, yet here you are coding.
@@UA-camrUser000 most of the time yes... do people apply themselves to get into that 'career field'?, nope
Man, this is super cool! I never thought about the unrealistic physics in other video games, and I respect the time and effort you've taken to create this passion project
Definitely looking forward to your next upload!
your passion burns throughout the whole video. Im making a mech game that involves air combat(might extend to space battles) and fighter jet target systems and your in depth explaination really helps me understand more about the essence these games strive to recreate, thank you and subscribed.
17:06 The reason you use the cross product is because the g vector is perpendicular to both the velocity vector of the aircraft and the rotation vector of the turn that craft is making. Due to the fact that the rotation vector is always perpendicular to the velocity vector in most maneuvers, the magnitude of the g load is equal to the product of the magnitudes of the velocity and rotation vectors, hence why the math works out like that.
I hope that makes sense
THE PHYSICS SUBSTEP IS GENIUS!!! SOLVED MY PROBLEM ON A INDIVIDUAL SURFACE SIMUATION!
I;m amazed by the amount of effort you put in the presentation to explain the physics in detail, which non other video on UA-cam about flight physics for game dev has done. Great job. You deserve a lot more sub and view
Wow... I was just looking for a cool HUD for a learning project I am doing... Ended up getting a class in flight physics... Amazing work and even more amazing you shared it all with everyone. Thank you
As a game developer I'm impressed on how you did this!
you are my professor.... idk why you did this and made it open source, bravo! many many respect!
One thing Ive been looking in flight sims is the feature to create dynamic campaigns. Sure having a good model is the main thing but what you need it for is also important
This is incredible. Thank you so much for releasing the source code
This is so easy to follow. You did a great job keeping the material clear and concise. Great work!
Thank you so much for such detailed but clear presentation.
THIS IS WHAT I NEED, a More Realistic Physics, Ace Combat, people think doing Cobras on AC is fun but doing a Cobra in a more realistic game is satisfiying as fuck
I can't figure out how to have cobra in it and also have realistic nose pulling dogfights
19:06 Absolute perfection!
Yeah, I've totally lost it there :D :D :D
Awesome! So well explained, thanks!
Firstly, absolutely great tutorial. Love it.
I've calculated drag in the full formula way. It's easy, because you have several of those numbers as constants, so you can precalculate them (I did it on the paper, basically) and you'll have realistic calculation in the end. (the part of it is the drag area which has findable values of say 0.3 times the area, which you can calculate per axis).
You can use real engine force, real drag coefficients, real lift values of a given plane and it will fly comparably... (as in, it's not a sim, but it kinda acts like one). My jet could achieve the real max speeds, climbs etc. with an error of a few percents without me tweaking anything.
You are going the hand tweak route, which will need much more tweaking as compared to tweaking the "real" values a bit (from my experience).
Seeing your rotations - I was simulating it more realistically and then I've implemented Fly By Wire on top of it (player rolls, plane also pitches, so FBW compensates the pitch).
You could try that, it was a fun thing to try to implement and I've personally enjoyed the end result, where the plane can be twitchy and self correcting. It was what made it feel "physical".
@@GonziHere how did you go about implementing Fly By Wire in unity? seems interesting to try
Found this from reddit. Your tutorial blog posts are awesome!
Visuals are very helpful and quick. Nice
This is one of the best approachings to putting together flight in unity. It's still slightly too realistic - at first - but it's an awesome way to build gameplay around flying skills. I've been playing with this for a few days now - I ran into a weird bug I cannot trace the source off. After a couple of seconds or more, I lose all lift in all surfaces - with gizmos visible I can see them just getting smaller fast and disappearing. I use the stock airfoils with reduced lift and drag for (75 and 35 respectively).
This can be a very successful asset store template with minimal additions: 1) multiple targets, 2) rotor planes (biplane and mono) 3) slightly more arcade controls 4) sound support. I would be more than happy to provide whatever art you need to help you put this up on the asset store (or just upgrade the git project).
edit - resetting the collision box on the plane to its original scale/values solved the problem.
This is one of the best resources - however, after following the tutorial and spending hours looking through the source code, I cannot figure out how the inputs are actually called. I understand you're using the new unity input system, however, the two primary scripts "Plane" and "PlayerController" seem to never actually reference the function "OnRollPitchInput" or "SetThrottleInput" - am I missing something?
Great video! Looking forward for the next part.
AceCombat and Project Wingman both have more involved physics than what you have shown here. They just have the weapons and AI configured to make it easy, but energy, stall, induced drag - they have all of that. I loved to play around the time of AC3-ACX and you could absolutely ignore tactics but if you do consider your mission target, the aircraft you have, its configuration and loadout and fly according it makes a big difference.
Some aircrafts there had abysmal low speed acceleration and high induced drag for yaw. So if you keep some height, don't turn too hard and stay at cruise speed the aircraft feels a lot more nible and getting a solid lockon becomes way easier.
I'm amazed! Thank you for this piece of art!
Loved the video. You have big potential boy
I kinda wanna make all the forces apply at the appropriate positions instead of always at center of mass, the program a flight stability assist computer and this can be damaged by bullets or electrical failure
Very interesting introductory video with awesome animations! gg.
Thank you man, I have been trying to make a flying simulator for so long, this tutorial is so helpful.
20:54 Average Delta wing
Just found this series. Looks amazing!
Can I program it to work with a keyboard and a mouse (like war thunder for example)?
I don't have a lot of coding experience(only scratch), how hard will programing it like this be?
Is there any chance you will make a short video about it?😬
Thanks!
Simply amazing!
best line of the whole video: "Dont ask me why, because I discovered it by accident"
1st sentence got me dieing - I like to play flight sims as Ace combat and project wingman 💀💀💀
Over G fighters was a solid midline between sim and arcade
Great video. The result is stunning!! I have one little question. The definition angle of attack wouldnt be the angular difference between the velocity and the nose of the plane, instead of the angle between y and z components of velocity right away??
Sheeesh, nice video man! Learned a lot from this, btw I have a question.. At low speeds the aircraft tends to preserve momentum from it's previous direction when turning, how do I prevent this from happening? I just can't seem to figure it out
That's intended behavior. At low speeds, the plane creates less lift, so when you turn, the velocity will take more time to align with the new direction you're facing
Ah you don't know about the beloved flight sim series back in the days of DOS and win 98, the Jane's combat simulations series like USAF or Fighters anthology.
You should try out IL-2, it's a WW2 flight simulator that is basically in between War Thunder and DCS in terms of Complexity and Realism
This is really awesome tutorial video great work man.
I've wanted to do this for a long time.
THANKS
🐦
Very nice overview on the calculated forces and flight mechanics in general. Maybe you can add keyboard+mouse control to your demo too.
thanks for the tutorial, it was really helpful. I am new to Unity3D and C# and I wish to learn more from you.
All you need to do is make the turn force depend on how much the control surfaces are deflected
Really great video, makes me want to whip out an old compute shader I wrote that uses a low resolution transparent normal render (rendered from the current ortho perspective of the wind) for calculating the per pixel forces and torques. I decided I ultimately needed someone who really knew their planes and shit to have it match a traditionally aggregate simulated formula. Thoughts?
amazing video, very well explained thank you for this
I like how the plane just turns into smoke
Great video, commenting for the algorithm!
You could get Rho based on player altitude by using the perfect gas law.
Nah, you need both temperature and pressure for that. Can just use a lookup table or a basic scale height equation though
vert underrated
Superb work on this!
Im having the problem that I was going to change the input to mouse and keyboard, and I changed it all in the "PlayerInput", but it does not work, I tried to debug it but nothings working. Is it using a different input system? help.
You can make it so that the pilot can endure higher G-Force for a short amount of time.
super great I will try in MSPhysics too.
What kind of settings are needed to have slow, realistic turning for scissors etc AND cobras and kvochur bell maneuvers?
Edit: It seems the G limiter is what prevents a cobra maneuver, for which you need to get 90 AoA and keep altitude almost the same.
Let's say G pitch limit is 10. The maneuver can't happen, you just turn upwards, seems to be the case at all speeds.
But if the g limit was let's say 20, the Gs pulled in the cobra don't even reach 10. It's just that if the limit was 10 it wouldn't be allowed.
Does that make sense?
Would love to hear your thoughts on a 2D-game that re-creates a cockpit screen. For example, in the game DCS:AH-64D there is a weapons MPD (multi-purpose-display) where you can select missiles and code them for the target.
The game would take user-input, update the screen, and issue a sound. Would Unity be the preferred tool?
When turning, shouldn't the nose of the craft experience a force pushing it back towards the direction of movement? Currently it seems as if when I nose up and then let off the controls, the nose "sticks" where I left it, whereas it seems as if other flight games model how air resistance exerts a force on the plane so that it turns back in the direction it is headed.
I'm probably not explaining it super well, but I was wondering how to implement this in my own project.
You're right, there should be a force like that. That's the stability force that real planes experience. A simple way to model it is by applying a torque that multiplies with AOA.
I did not include it in my simulation for simplicity. The way the plane behaves is like a plane with neutral stability (holds nose attitude). A more realistic behavior would be to have positive stability (nose pulled towards velocity vector).
Thanks man! But my one problem is that none of the inputs work even when I plug in my controller
Killer. Keep going bro
Great Video! I think you could maybe have shortend the implimentation and formular derivation part. Since it think most of it is straight forward. Thanks for the nice project. I'm interested where it's headed :)
8:32 how do you add specific keybinds for the throttle?
Could this be expanded to a space sim kinda game? Having a seamless transition from space to atmosfere fligh, like kerbal or a more realistic star citizen? Or would this solution feel too arcady for a more simulation like game?
I'm trying to remake this on UE5 but nothing works on UE someone can help?
Great tut, thanks.
Can you do tutorial videos about the tank you uploaded on UA-cam?
Bro... The flap are inverted normally if you want to create a up lift you make the flap point down
Great work.
Hey if you like tiny combat arena you should check out Strike Fighters 2
Amazing
Hey man quick question, why did you multiply the local velocity on the y axis by negative one while calculating the angle of attack? Great work by the way!
I wanted AngleOfAttack to be positive when the nose direction is "above" the velocity direction. If I just used the velocity.y component directly, the AOA would be opposite of what I wanted. This problem could also be solved by pulling the negative outside of the function ( -Mathf.Atan2(...) ).
Basically, the math behind Atan2 would make the value negative, so I need to multiply by -1 somewhere
One downside though, I seem to be able to go straight up, and after around 3 minutes of climbing I'm still going at 85% of my max speed and it's not going any lower
In reality you could not climb completely vertically for an infinite amount of time, you would lose a lot of velocity very fast
I'm trying to follow along, but I can't figure out how to implement inputs for the throttle, which makes it impossible to test if the thrust and inertia stuff is working. What part of the github repository should I be looking in?
Ive tried making my own jet and i copy the code and do what it said and theres a bunch of error messages, i think it needs a bunch of floats added to make it work but i still dont know what to add where. please could you make a follow up video walking us through every process
great vid man :D :)
I'm surprised you hand-tuned the coefficient of drag curve with AoA. It seems like it would be easier and more realistic to estimate the cross-sectional area of the plane with AoA (say, linearly interpolate between the nose-om area and the belly-on area) then you would just have to tune a single scalar and the dependence of AoA should be very realistic without any more calculations than you're already doing.
The coefficient of drag uses an animation curve based on air speed. The Scale6 function does sort of blend between nose-on drag and belly-on drag. However it specifies the drag coefficient directly instead of calculating based on area. The game designer could do those calculations offline and simply plug in the numbers.
How did you made the camera?
@Vazgriz How do I land the plane? it keeps crashing.
How did you make the animation curve for Cl vs alpha? Need a bit help with that. Please guide me with the steps.
I used airfoiltools.com to find the data for the F-15's wing (which is a symmetrical wing). Then I plotted the data in Excel.
would you mind if i used code from this in a game i am making? it will be free if i post it anywhere.
The github repo is MIT licensed. So there are very few restrictions and I don't mind.
The Scale6 function is a really nice idea, I can see myself using it for other things too :)
*For those whose plane refuses to leave the ground:* My plane refused to get off the ground since aoa = 0 hence CL = 0 and lift = 0, so I had to add an angle of incidence (set by user in degrees, converted to radians) to the angle of attack, this will also make the simulation more realistic since most planes have their wings rotated slightly backwards
This is a really nice video explaining angle of incidence:
ua-cam.com/video/AUmL8mIUxyc/v-deo.html
0:42 dcs also has insane storage space for my tiny ass laptop
if you think of the grind as fun playime, not agonizing grinding, war thunder is quite fun
how to download!!
Thank you
Can the code be used for the fbx extension?
The code is all red maybe it’s because I’m using C# I thought that was what you were using 😅
and what coding language is this ❤
How did you avoid gimbal lock?
Awesome! Can you use the pc keyboard to play this in Unity?
No. Only gamepad control is implemented. You can of course download the project and implement it yourself.
I bought a controller just for this. The experience is so much better.
@@Vazgriz can you help me implement keyboard input
Damn, dcs getting called nerdy. Wow.
I dont understand why Utilities is without context but I don't see you declare it in the codes
The Utilities class is defined in Utilities.cs in the Github repo. It contains some math functions that are fairly simple and used in multiple places in the code.
Note: "AngleOfAttackYaw" is more professionally called Angle Of Slip. Hope this helps!
where were this tutorial when I needed?
is this able to translate to unreal engine ?
MOOORRREEEEE PPPLLLLSSSSS
I got a problem, none of the controls work
where do i put the code...
Hi the f15 does not show up for some reason i dont know why but can someone help me?
And wich version is he using
You need to download the files using git LFS, otherwise the project will be corrupted. This project was made with Unity 2021.3.10f1
@@Vazgriz Ok thanks
@@Vazgriz Zip or Other thing
Make a thrust Vectoring plane plzzz
can I make a PR that implements redding out/exploding pilot heads?
does this still work? I tried downloading the project but the prefabs dont work and same with the terrain
Did you download it with Git LFS?
@@Vazgriz no i didn't how do i do that
edit: Nevermind i got it