Simple Physics Based Plane Controller in Unity

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024
  • เกม

ความคิดเห็น • 101

  • @JonHuhnMedical
    @JonHuhnMedical ปีที่แล้ว +26

    Thanks for this, the simplicity was helpful. I'm not an aeronautics guy either, but if I may, your lift vector should be perpendicular to the direction of air moving over the wing, although you can simplify that in this situation to just be perpendicular to the wing. So the lift is applied in the direction of rb.up instead of Vector3.up. Cheers!

    • @b3agz
      @b3agz  ปีที่แล้ว +3

      Thanks! I'll pin this so others can see it.

    • @JonHuhnMedical
      @JonHuhnMedical ปีที่แล้ว +6

      @@b3agz (And just to beat this dead horse a bit more...) This will give you a much more realistic feel to the flight. If flying straight and level at a given speed, it means your lift is perfectly counteracting gravity. Then, when you bank, the lift is no longer perfectly opposed to gravity, so the nose will start to drop in the bank (the center of gravity may need to be forward of the center of lift to see the drop. At a minimum, you'll see the direction of flight vector drop below the horizon, anyway!) To counteract this dropping of the nose during the bank, you pull back on the stick to level out your flight. But since your lift vector is tilted, part of the effect of pulling back on the stick is that you turn horizontally... And this is primarily what causes you to turn during a bank! (I think the rudder contributes some, but I'm not sure it's as much). Any pilots or aeronautics guys please jump and and correct me if I'm wrong. Thanks!

    • @b3agz
      @b3agz  ปีที่แล้ว +8

      It was a *simple* plane controller 😂

    • @JonHuhnMedical
      @JonHuhnMedical ปีที่แล้ว +4

      @@b3agz ha ha, sorry :)

    • @thatprogrammerjack747
      @thatprogrammerjack747 ปีที่แล้ว

      I've tried it, but Rigidbody doesn't have a property for up. Any suggestions?

  • @JtagSheep
    @JtagSheep ปีที่แล้ว +10

    I would love to see this develop along with a physics based boat with bouyancy and a physics based helicopter. Great work!

  • @lorenmax2.013
    @lorenmax2.013 ปีที่แล้ว

    Awesome video, loved the audio, your voice is crisp and clear, and your accent is flawless. Thanks for the guide!

  • @Incognito...
    @Incognito... ปีที่แล้ว +14

    pov: war thunder alpha 0.0.1

  • @dalmaujoan
    @dalmaujoan 7 หลายเดือนก่อน

    Really amazing and useful tutorial. It helped a lot creating my plane controller. Thanks!

    • @b3agz
      @b3agz  7 หลายเดือนก่อน

      Great to hear!

  • @Mattd547
    @Mattd547 ปีที่แล้ว

    Thank you for this excellent tutorial. It was exactly what I was looking for, and was clearly explained.

    • @b3agz
      @b3agz  ปีที่แล้ว

      Glad it helped!

  • @GrevMivlos
    @GrevMivlos ปีที่แล้ว

    Thanks for this b3agz!
    Would love to see your take on a physics based boat controller with water!

    • @b3agz
      @b3agz  ปีที่แล้ว +1

      I've had a few requests for that so yeah, it's on the list 🤓

    • @JtagSheep
      @JtagSheep ปีที่แล้ว

      @@b3agz Could you also add a physics based helicopter too ;), there arent many tutorials based on helis and if there are they seem to be years old.

  • @leeburton7901
    @leeburton7901 5 หลายเดือนก่อน

    Really struggling with this and would love some help, followed everything but my plane goes to the side when I press space, ive tried rotating my plane, camera etc.. the only way I get it going forward my plane is one its side haha.. also my pitch and roll are reversed, I've made sure the input settings are correct. Thanks in advance for any help!

  • @emememememememet33
    @emememememememet33 ปีที่แล้ว

    Muchas Gracias por el tutorial esta increíble, ayudaste mucho a un amigo mexicano :)

  • @cptfurball
    @cptfurball ปีที่แล้ว

    Ah thanks for the tutorial! Was looking for something like this :D

    • @b3agz
      @b3agz  ปีที่แล้ว

      Hey CptFurball, welcome! And thanks, glad people are finding it useful.

  • @thatprogrammerjack747
    @thatprogrammerjack747 ปีที่แล้ว +1

    Excellent tutorial. Easy to follow and simple to understand. There appears, however, to be a problem with lift - which is to say that there is none :p I altered the lift value at runtime to see if I could change the minimum airspeed threshold for takeoff, but it took not at 240f, but at over 200 million - at which point it accelerated upward at an exponential rate so ludicrous as to take me to the physically-based sky's planet view in HDRP. I may have done something wrong lol

  • @MaxFr26
    @MaxFr26 3 หลายเดือนก่อน

    can you make the plane script copy paste? it doesnt work for me

  • @athithyaparamesh8251
    @athithyaparamesh8251 ปีที่แล้ว

    My plane can pitch but the yawning and rolling are not working. The input of yaw and roll are perfectly recognized though. Any idea?

  • @not_notapplicable
    @not_notapplicable ปีที่แล้ว +2

    this is a more complicated physical plane controller toturial i made;
    th-cam.com/video/vpf4QnWO20c/w-d-xo.html

  • @jaya.1610
    @jaya.1610 ปีที่แล้ว

    I get an error (42,32): Operater '.' cannot be applied to operand of type 'void'. Any help ?? thanks

  • @harlowz
    @harlowz ปีที่แล้ว

    Im having a issue where the plane has like a weird physics drift effect, any advice?

  • @gigani...4363
    @gigani...4363 ปีที่แล้ว

    Any idea how to make the plane less responsive at high speeds?
    Tried adding rb.velocity.magnitude as component for rb.torque but didn't work☹

    • @Massive-3D
      @Massive-3D 7 หลายเดือนก่อน

      movement * multiplier float
      lower multiplier if higher speed

  • @felixfontain6423
    @felixfontain6423 ปีที่แล้ว

    THX

    • @b3agz
      @b3agz  ปีที่แล้ว

      YR WELCME

  • @munyunu
    @munyunu ปีที่แล้ว

    Wow!!!

  • @sumanth94
    @sumanth94 10 หลายเดือนก่อน

    can u share the script

  • @CalypsoAlex
    @CalypsoAlex ปีที่แล้ว +2

    I HAVE COPIED THE CODE TO EXACT BUT NOTHING WORKS

  • @unils3891
    @unils3891 ปีที่แล้ว +4

    This is truly amazing. I recently spent about a month trying to make a physics plane controller in unity but ended up with a buggy mess. I can't belive this was here all along. Keep up the great work!

  • @christo-j5507
    @christo-j5507 หลายเดือนก่อน +1

    Amazing tutorial, btw this airplane model reminds me of the Zero's mission in GTA San Andreas.

  • @slygamer01
    @slygamer01 ปีที่แล้ว +2

    Where did the 3.6 magic number come from when displaying airspeed? Physics operates in the same standard units, so the velocity of the rigid body should already be in m/s.

    • @b3agz
      @b3agz  ปีที่แล้ว +3

      Hi! Yes, if we use 1 unit to be 1 metre, we're already in in metres per second. The 3.6 number is convert our m/s to km/h. 60 seconds in a minute multiplied by 60 minutes in an hour = 3,600 metres per hours. Divide by 1,000 = 3.6 kilometres per hour.

  • @SteffDev
    @SteffDev ปีที่แล้ว +2

    I usually update camera's position in the LateUpdate loop, I think that you could still get jitter and interference if updating it together with the rest of the physics objects

    • @ImmortalPanic
      @ImmortalPanic 11 หลายเดือนก่อน +1

      This fixed my jitters thanks🙌

  • @blueme3021
    @blueme3021 2 หลายเดือนก่อน

    Great tutorial. I wish you added some breaks to the plane .

  • @aaronbitrolf1613
    @aaronbitrolf1613 หลายเดือนก่อน

    loved the tutorial, much appreciated

  • @rehmozayub9442
    @rehmozayub9442 ปีที่แล้ว +2

    I'm having trouble with the orientation of my model aircraft's local axes. They are different from the global axes, and when I apply a roll input, it generates pitch instead. I want to adjust the local axes' orientation so that roll input generates roll, not pitch. How do I do that? I am importing the aircraft into a new scene, not the built-in that comes with the asset.

    • @gamesscow2382
      @gamesscow2382 ปีที่แล้ว

      I dont know if you ever solved this. but just double check your inputs. for me the alt inputs for yaw and pitch were the same so both yaw and pitch were essentially being activated at the same time. Hope this helps

    • @rehmozayub9442
      @rehmozayub9442 ปีที่แล้ว

      @@gamesscow2382 Thank you for the reply. I solved it by creating a new scene where the world axes were the same direction as aircraft axes. I had no trouble with alt inputs. Another way to solve this issue is to create a new coordinate system and making the aircraft its child object. But it increases code complexity and that's why I decided to go with the first approach.

    • @gamesscow2382
      @gamesscow2382 ปีที่แล้ว +2

      @@rehmozayub9442 You could put the plane into an empty object with all of the code on that object then just rotate the plane to the correct orientation

    • @rehmozayub9442
      @rehmozayub9442 ปีที่แล้ว +1

      @@gamesscow2382 yes that's what I meant in the last reply but it was creating some complications (I don't remember what exactly) and I took the easier way out.

  • @PostVROfficial
    @PostVROfficial ปีที่แล้ว +1

    This is such a good tutorial and explanation! You are like the new brackeys or something, i really like your teaching style! Keep it up!

  • @keremgokturkulutas4786
    @keremgokturkulutas4786 ปีที่แล้ว +1

    thanks for this perfect, best, simplest and easy to understand tutorial.

  • @octopiusprogramming4321
    @octopiusprogramming4321 ปีที่แล้ว +1

    Thank you!, this is the best tutorial

  • @littlehuzz
    @littlehuzz 7 หลายเดือนก่อน

    My plane keeps moving to the side when i tell it to go forward using the up arrow, i have no idea why.

    • @anonymousl299
      @anonymousl299 7 หลายเดือนก่อน +1

      try to increase mass in rigidbody

  • @11muffins
    @11muffins ปีที่แล้ว

    thank you i was makeing a game for my brother cause he's a piolit and your video helped me alot(:

  • @Claseeimperial
    @Claseeimperial 11 หลายเดือนก่อน

    Hi friend, could you help me? Because my plane, even with the Throttle at 1%, has 1000KM\h, how can I solve this?

  • @RetroSteve0
    @RetroSteve0 หลายเดือนก่อน

    Amazing people like you are what allows nobodies such as myself live out my dreams of making my own flight sim.

  • @3h53
    @3h53 5 หลายเดือนก่อน

    10:26

  • @lungomungo
    @lungomungo ปีที่แล้ว

    im having a problem where i nose dive intentionally and lost airspeed and when i point my nose up the airspeed increases. kinda weird. anyone help?

  • @Build_the_Future
    @Build_the_Future 11 หลายเดือนก่อน

    What about Gamble lock? How would you deal with that?

  • @bmuraaz6024
    @bmuraaz6024 ปีที่แล้ว

    thanks for the tutorial, but is there any way of using mouse control to move the plane left or right? thank you.

  • @HiddenShadow206
    @HiddenShadow206 ปีที่แล้ว

    it gave me errors when i tried it and I spent hours trying to fix it can anyone reply to this and past a code that works?

  • @KBforJesusChrist
    @KBforJesusChrist ปีที่แล้ว

    How can I get that auto complete mine is frustrating I'm using the unity auto complete.

  • @krikol_77
    @krikol_77 6 หลายเดือนก่อน

    Thanks a lot, it does the job very well !

  • @StigDesign
    @StigDesign ปีที่แล้ว +1

    Love the detailed tutorial :D

  • @tyen2231
    @tyen2231 ปีที่แล้ว

    Hey, so when I do a 180 turn the plane just flys in the direction it flew how to fix it?

  • @epicboi3213
    @epicboi3213 ปีที่แล้ว

    Aeronautic wise, this is ridiculous(ly fun). But for me a beginner in unity, this was gold

  • @StanleySipos
    @StanleySipos 11 หลายเดือนก่อน

    what is additional camera data script

  • @alexeybunin2927
    @alexeybunin2927 7 หลายเดือนก่อน

    Thanks for the lesson he’s great! 😍 You can make the physical material and put it in the collider, the fields will be put at zero, friction combine: minimum, and then your plan will normally move on the ground

    • @b3agz
      @b3agz  7 หลายเดือนก่อน

      Great tip!

  • @CozmoDev
    @CozmoDev ปีที่แล้ว +3

    PRO TIP: Use Cinemachine for the camera.
    Step 1: Put Cinemachine in project
    Step 2: Create Virtual Camera
    Step 3: Make it look at a new parent for the plane, but follow the plane
    Step 4: Adjust viewing
    Step 5: Enjoy working cinematic camera

  • @ipodtouch
    @ipodtouch 6 หลายเดือนก่อน

    This tutorial was so good. Clearly explained, calm, and funny too! Well done :)

    • @b3agz
      @b3agz  6 หลายเดือนก่อน

      Thanks so much!

  • @AllyG1967
    @AllyG1967 ปีที่แล้ว

    Hi there, I'm stuck :( Have copied the code exactly (I hope) no errors when I drag and drop onto my model. However, there's no movement of the model as at 10:00. It's like the input controller isn't being recognised. Any ideas? Thanks

  • @juligantos
    @juligantos ปีที่แล้ว

    Whoa, another vid, and so soon?!

  • @AvarageMilkEnjoyer
    @AvarageMilkEnjoyer ปีที่แล้ว

    Thanks!

  • @dhakerbadri8040
    @dhakerbadri8040 ปีที่แล้ว

    MOOOOOOOOREEEE VIDEOOOOS

  • @pumpkindev4506
    @pumpkindev4506 ปีที่แล้ว

    amazing

  • @217tman3
    @217tman3 ปีที่แล้ว

    nice

  • @lahcenebelbachir7929
    @lahcenebelbachir7929 ปีที่แล้ว

    Genius.

  • @Eqqs
    @Eqqs ปีที่แล้ว

    Thank you!

    • @b3agz
      @b3agz  ปีที่แล้ว +1

      You're welcome!

  • @redcubedev
    @redcubedev ปีที่แล้ว +4

    Bold of you to assume that im not a pilot.

    • @b3agz
      @b3agz  ปีที่แล้ว

      I assume you are everything 🥹

    • @redcubedev
      @redcubedev ปีที่แล้ว

      @@b3agz well you were right im not a pilot 😌

    • @rapho8539
      @rapho8539 ปีที่แล้ว

      lol

  • @Byteezexe
    @Byteezexe ปีที่แล้ว

    My plane is to slow

    • @b3agz
      @b3agz  ปีที่แล้ว

      Hi. We control the plane with 1-100 "throttle" value, it's basically a percentage of the engine force. To make it go faster, increase the engine force.

    • @Byteezexe
      @Byteezexe ปีที่แล้ว

      @@b3agz ok thanks

  • @yukirintarou
    @yukirintarou ปีที่แล้ว +1

    Please give link for script

  • @khhs
    @khhs ปีที่แล้ว +1

    First?

    • @b3agz
      @b3agz  ปีที่แล้ว

      It appears you are.

  • @ultrawaveyt5582
    @ultrawaveyt5582 ปีที่แล้ว

    is there a download link for the script? I understand it but i dont want to type the whole thing out

  • @da1memer192
    @da1memer192 ปีที่แล้ว

    what is alpha1/2/3/4