Creating a Flight Simulator in Unity3D (Part 1)

Поділитися
Вставка
  • Опубліковано 22 лис 2024

КОМЕНТАРІ • 150

  • @chiefcloudyeye0489
    @chiefcloudyeye0489 2 роки тому +75

    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!

    • @Alimentasable
      @Alimentasable 2 роки тому +3

      Guy has 3k subs, the video was barely an hour old when you commented. Stop being so dramatic

    • @MassimoRough
      @MassimoRough 2 роки тому

      Then share this video on your social media.

    • @quincyames2014
      @quincyames2014 Рік тому

      bad intro lol

    • @sladethegreat1194
      @sladethegreat1194 8 місяців тому

      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.

  • @picklechin2716
    @picklechin2716 11 місяців тому +76

    You call me nerdy for playing dcs, yet here you are coding.

    • @amaranth6174
      @amaranth6174 Місяць тому +1

      @@UA-camrUser000 most of the time yes... do people apply themselves to get into that 'career field'?, nope

  • @TrentonV
    @TrentonV 2 роки тому +42

    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!

  • @supm8te751
    @supm8te751 Рік тому +6

    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.

  • @TheNerd484
    @TheNerd484 2 роки тому +28

    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

  • @claxvii177th6
    @claxvii177th6 2 роки тому +2

    THE PHYSICS SUBSTEP IS GENIUS!!! SOLVED MY PROBLEM ON A INDIVIDUAL SURFACE SIMUATION!

  • @NDSno1
    @NDSno1 Рік тому +3

    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

  • @itodobien1396
    @itodobien1396 Місяць тому

    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

  • @M4ssExtinction
    @M4ssExtinction Рік тому

    As a game developer I'm impressed on how you did this!

  • @OmPuter
    @OmPuter Рік тому +1

    you are my professor.... idk why you did this and made it open source, bravo! many many respect!

  • @AlgorithmicHearts
    @AlgorithmicHearts Рік тому +1

    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

  • @sdsdfdu4437
    @sdsdfdu4437 Рік тому +5

    This is incredible. Thank you so much for releasing the source code

  • @RyanLee-up9ej
    @RyanLee-up9ej Рік тому +5

    This is so easy to follow. You did a great job keeping the material clear and concise. Great work!

  • @yah3136
    @yah3136 2 роки тому +3

    Thank you so much for such detailed but clear presentation.

  • @RogueBeatsARG
    @RogueBeatsARG 6 місяців тому +1

    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

    • @panickal
      @panickal 4 місяці тому

      I can't figure out how to have cobra in it and also have realistic nose pulling dogfights

  • @BlackM3sh
    @BlackM3sh 2 роки тому +2

    19:06 Absolute perfection!

    • @GonziHere
      @GonziHere 2 роки тому +1

      Yeah, I've totally lost it there :D :D :D

  • @cgpilk
    @cgpilk 2 роки тому +4

    Awesome! So well explained, thanks!

  • @GonziHere
    @GonziHere 2 роки тому +1

    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).

    • @GonziHere
      @GonziHere 2 роки тому +1

      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".

    • @akshatmaurya3964
      @akshatmaurya3964 Рік тому

      @@GonziHere how did you go about implementing Fly By Wire in unity? seems interesting to try

  • @dreamisover9813
    @dreamisover9813 2 роки тому

    Found this from reddit. Your tutorial blog posts are awesome!

  • @sayochikun3288
    @sayochikun3288 Рік тому +1

    Visuals are very helpful and quick. Nice

  • @larryneagu1180
    @larryneagu1180 Рік тому +5

    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.

  • @baxterclagmoar9333
    @baxterclagmoar9333 2 місяці тому +2

    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?

  • @narvi2
    @narvi2 2 роки тому +1

    Great video! Looking forward for the next part.

  • @ABaumstumpf
    @ABaumstumpf Рік тому

    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.

  • @jagc3763
    @jagc3763 2 роки тому +1

    I'm amazed! Thank you for this piece of art!

  • @lukarausch7907
    @lukarausch7907 2 роки тому +1

    Loved the video. You have big potential boy

  • @brodakarat6340
    @brodakarat6340 Рік тому +1

    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

  • @imDanoush
    @imDanoush Рік тому

    Very interesting introductory video with awesome animations! gg.

  • @EeveeMae
    @EeveeMae Рік тому

    Thank you man, I have been trying to make a flying simulator for so long, this tutorial is so helpful.

  • @fuzzybloodpc9291
    @fuzzybloodpc9291 Рік тому +1

    20:54 Average Delta wing

  • @galsmith2098
    @galsmith2098 Рік тому +1

    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!

  • @AterNyctos
    @AterNyctos 5 місяців тому

    Simply amazing!

  • @jaybabcock9123
    @jaybabcock9123 Рік тому

    best line of the whole video: "Dont ask me why, because I discovered it by accident"

  • @michalkmet8351
    @michalkmet8351 Рік тому

    1st sentence got me dieing - I like to play flight sims as Ace combat and project wingman 💀💀💀

  • @zantherhayes7229
    @zantherhayes7229 Рік тому

    Over G fighters was a solid midline between sim and arcade

  • @albertomodrono4320
    @albertomodrono4320 11 місяців тому

    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??

  • @r4c732
    @r4c732 Рік тому +1

    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

    • @Vazgriz
      @Vazgriz  Рік тому

      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

  • @FullMetal-Tech
    @FullMetal-Tech Рік тому

    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.

  • @ARandomHumanBein
    @ARandomHumanBein Рік тому +1

    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

  • @RUDERUDYTUTORIALS
    @RUDERUDYTUTORIALS Рік тому

    This is really awesome tutorial video great work man.

  • @larrysouthern5098
    @larrysouthern5098 Рік тому

    I've wanted to do this for a long time.
    THANKS
    🐦

  • @vast634
    @vast634 Рік тому +1

    Very nice overview on the calculated forces and flight mechanics in general. Maybe you can add keyboard+mouse control to your demo too.

  • @michaelalaku1536
    @michaelalaku1536 2 роки тому

    thanks for the tutorial, it was really helpful. I am new to Unity3D and C# and I wish to learn more from you.

  • @TheBuccaneerIsHot
    @TheBuccaneerIsHot Місяць тому

    All you need to do is make the turn force depend on how much the control surfaces are deflected

  • @chad-wyck
    @chad-wyck 3 місяці тому

    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?

  • @HarshitRana57
    @HarshitRana57 4 місяці тому

    amazing video, very well explained thank you for this

  • @markaron9356
    @markaron9356 Рік тому

    I like how the plane just turns into smoke

  • @justhanging2569
    @justhanging2569 Рік тому

    Great video, commenting for the algorithm!

  • @ChucksSEADnDEAD
    @ChucksSEADnDEAD 2 роки тому

    You could get Rho based on player altitude by using the perfect gas law.

    • @badbeardbill9956
      @badbeardbill9956 Рік тому

      Nah, you need both temperature and pressure for that. Can just use a lookup table or a basic scale height equation though

  • @smollime117
    @smollime117 2 роки тому

    vert underrated

  • @fishercawkey
    @fishercawkey Рік тому

    Superb work on this!

  • @GreekRussian367
    @GreekRussian367 8 місяців тому +1

    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.

  • @darkveneno6155
    @darkveneno6155 Рік тому +1

    You can make it so that the pilot can endure higher G-Force for a short amount of time.

  • @MSPhysicsForFun
    @MSPhysicsForFun Рік тому

    super great I will try in MSPhysics too.

  • @panickal
    @panickal 4 місяці тому

    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?

  • @bennguyen1313
    @bennguyen1313 Рік тому

    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?

  • @joshuasteward6672
    @joshuasteward6672 9 місяців тому

    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.

    • @Vazgriz
      @Vazgriz  8 місяців тому

      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).

  • @RecHorrors
    @RecHorrors Рік тому +1

    Thanks man! But my one problem is that none of the inputs work even when I plug in my controller

  • @R1kyzzzz
    @R1kyzzzz Рік тому

    Killer. Keep going bro

  • @TheDreamFx
    @TheDreamFx 2 роки тому

    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 :)

  • @Firebend11
    @Firebend11 7 місяців тому

    8:32 how do you add specific keybinds for the throttle?

  • @naronga6857
    @naronga6857 Рік тому

    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?

  • @DjblackgameBlackgamers
    @DjblackgameBlackgamers 8 місяців тому +1

    I'm trying to remake this on UE5 but nothing works on UE someone can help?

  • @MrZtapp
    @MrZtapp 9 місяців тому

    Great tut, thanks.

  • @MinhLuong1006
    @MinhLuong1006 6 місяців тому

    Can you do tutorial videos about the tank you uploaded on UA-cam?

  • @daxylikecatz7050
    @daxylikecatz7050 Рік тому

    Bro... The flap are inverted normally if you want to create a up lift you make the flap point down

  • @CYON4D
    @CYON4D Рік тому

    Great work.

  • @taktischesgenie331
    @taktischesgenie331 Рік тому +1

    Hey if you like tiny combat arena you should check out Strike Fighters 2

  • @pygarg26
    @pygarg26 5 місяців тому

    Amazing

  • @bedirhansakaoglu8767
    @bedirhansakaoglu8767 2 роки тому

    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!

    • @Vazgriz
      @Vazgriz  2 роки тому +1

      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

  • @valentinstudio3334
    @valentinstudio3334 9 місяців тому

    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

  • @bubchudlar5629
    @bubchudlar5629 Рік тому

    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?

  • @Aventis_Aerospace
    @Aventis_Aerospace Рік тому

    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

  • @randomdude5634
    @randomdude5634 7 місяців тому

    great vid man :D :)

  • @PC_YouTube_Channel
    @PC_YouTube_Channel 2 роки тому

    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.

    • @Vazgriz
      @Vazgriz  2 роки тому +1

      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.

  • @GabrielxC
    @GabrielxC Рік тому +1

    How did you made the camera?

  • @TheOfficalCorrieR2
    @TheOfficalCorrieR2 8 місяців тому

    @Vazgriz How do I land the plane? it keeps crashing.

  • @sapphiregaming4360
    @sapphiregaming4360 Рік тому

    How did you make the animation curve for Cl vs alpha? Need a bit help with that. Please guide me with the steps.

    • @Vazgriz
      @Vazgriz  Рік тому

      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.

  • @a.s.b.
    @a.s.b. Рік тому +1

    would you mind if i used code from this in a game i am making? it will be free if i post it anywhere.

    • @Vazgriz
      @Vazgriz  Рік тому +1

      The github repo is MIT licensed. So there are very few restrictions and I don't mind.

  • @mrpotato8196
    @mrpotato8196 8 місяців тому

    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

  • @Firebend11
    @Firebend11 7 місяців тому

    0:42 dcs also has insane storage space for my tiny ass laptop

  • @blaisepascal3804
    @blaisepascal3804 Рік тому

    if you think of the grind as fun playime, not agonizing grinding, war thunder is quite fun

  • @swastikdas9687
    @swastikdas9687 Рік тому +1

    how to download!!

  • @torusx8564
    @torusx8564 2 роки тому

    Thank you

  • @thoufiqjabbarsilton5893
    @thoufiqjabbarsilton5893 4 місяці тому

    Can the code be used for the fbx extension?

  • @yahiagaming7053
    @yahiagaming7053 Рік тому +1

    The code is all red maybe it’s because I’m using C# I thought that was what you were using 😅

  • @newsystem3667
    @newsystem3667 Рік тому

    How did you avoid gimbal lock?

  • @grangerhighschoolvirtualre7070
    @grangerhighschoolvirtualre7070 2 роки тому

    Awesome! Can you use the pc keyboard to play this in Unity?

    • @Vazgriz
      @Vazgriz  2 роки тому

      No. Only gamepad control is implemented. You can of course download the project and implement it yourself.

    • @larryneagu1180
      @larryneagu1180 Рік тому

      I bought a controller just for this. The experience is so much better.

    • @tyen2231
      @tyen2231 Рік тому

      @@Vazgriz can you help me implement keyboard input

  • @mrcelsius2928
    @mrcelsius2928 Рік тому

    Damn, dcs getting called nerdy. Wow.

  • @generalindominus2722
    @generalindominus2722 Рік тому

    I dont understand why Utilities is without context but I don't see you declare it in the codes

    • @Vazgriz
      @Vazgriz  Рік тому

      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.

  • @greggory7655
    @greggory7655 Рік тому +1

    Note: "AngleOfAttackYaw" is more professionally called Angle Of Slip. Hope this helps!

  • @epich307
    @epich307 8 місяців тому

    where were this tutorial when I needed?

  • @daxmiller2670
    @daxmiller2670 9 місяців тому

    is this able to translate to unreal engine ?

  • @andreicristianfigula9961
    @andreicristianfigula9961 Рік тому +1

    MOOORRREEEEE PPPLLLLSSSSS

  • @higgzy8001
    @higgzy8001 2 роки тому

    I got a problem, none of the controls work

  • @Night_Assasin_13
    @Night_Assasin_13 Місяць тому

    where do i put the code...

  • @Daddyidkwhy
    @Daddyidkwhy Рік тому +1

    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

    • @Vazgriz
      @Vazgriz  Рік тому

      You need to download the files using git LFS, otherwise the project will be corrupted. This project was made with Unity 2021.3.10f1

    • @Daddyidkwhy
      @Daddyidkwhy Рік тому

      @@Vazgriz Ok thanks

    • @Daddyidkwhy
      @Daddyidkwhy Рік тому

      @@Vazgriz Zip or Other thing

  • @skyblox-eo5se
    @skyblox-eo5se Рік тому

    Make a thrust Vectoring plane plzzz

  • @choppedandspewed
    @choppedandspewed 2 роки тому +1

    can I make a PR that implements redding out/exploding pilot heads?

  • @reverse1895
    @reverse1895 8 місяців тому

    does this still work? I tried downloading the project but the prefabs dont work and same with the terrain

    • @Vazgriz
      @Vazgriz  8 місяців тому

      Did you download it with Git LFS?

    • @reverse1895
      @reverse1895 8 місяців тому

      @@Vazgriz no i didn't how do i do that
      edit: Nevermind i got it