Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AndreasX12 · May 02, 2014 at 07:51 PM · physicsplaneflightflyaircraft

Creating my own flight physics?

Hi. I'm trying to make some realistic flight physics.

First.. I'm trying to make the plane fly.

This is my aircraft: alt text

What would be my best approach on making flight physics?

This is my current script:

     int curr_Speed;
 
     float lift;
 
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
 
         curr_Speed = (int)(rigidbody.velocity.magnitude * 1 / 0.3f);
 
     }
 
     void FixedUpdate() {
 
         rigidbody.AddRelativeForce(transform.forward * 4.5f);
 
 
         }
 

This only make the plane move forward (of course). What would be my next step and where should I apply rotation forces?

Thanks in advance.

Andreas.

flight.png (236.3 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · May 02, 2014 at 10:14 PM 0
Share

Flight physics can be fairly complicated. If you are asking for design help, then Unity Forums is a better place to post. Unity Answers focuses on single, specific questions. There are packages in the Asset store (including one free one) just on flight physics. You can use AddRelativeTorque() to turn the plane.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by bhavinbhai2707 · Mar 26, 2017 at 08:38 PM

Probably u should try this script. . . .this is not really an advance script but just an example of where u can start

  //C# SCRIPT
  public float maxSpeed;            // Our maximum speed allowed.
  public float decAltSpeed;        //Decrease Altitude.
  public float incAltSpeed;        // Increase Altitude.
  public float curSpeed;            // Current Speed;
  public float applySpeed;        // How much force to apply (Forward).
  
  public float airBrakeForce;        // Breaks.
  
  private Rigidbody myRigid;        // Our Rigidbody.
  
  void Start(){
      myRigid = GetComponent<Rigidbody>();        // Gets the players Rigidbody.
  }
  
  void FixedUpdate(){
  
  curSpeed = myRigid.velocity.z;
  
  if(curSpeed >= maxSpeed){
      //If our speed maxes out to our maxSpeed we restrict our plane from going any faster.
      applySpeed = curSpeed;
  }
  
  
      if(Input.GetKey(KeyCode.W)){
          //Apply Accelleration
          myRigid.AddRelativeForce(Vector3.forward * applySpeed);
          if(curSpeed >=incAltSpeed){
              myRigid.AddRelativeForce(Vector3.up * AnyNumberYouWant);
          }
          
      }
      if(Input.GetKey(KeyCode.S)){
          //Apply BREAKS
          myRigid.AddRelativeForce(Vector3.back * airBrakeForce);
          if(curSpeed <= decAltSpeed){
              myRigid.AddRelativeForce(Vector3.down * AnyNumberYouWant);
          }
          }
          
      }
      
      
      void Update(){
          //NOT REALISTIC ROTATIONS
          
          //You may have to move the '-' sign to the other one (- means opposite) E.G. - Negative so I THINK -Vector.up is left. Could be wrong though.
          
          if(Input.GetKey(KeyCode.A)){
              transform.rotate(-Vector3.up * 15 * Time.deltaTime);
              
          }
          if(Input.GetKey(KeyCode.D)){
              transform.rotate(Vector3.up * 15 * Time.deltaTime);
              
          }
      }
      
  }

hope u can get a idea

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by theGugu · Mar 28, 2017 at 04:41 AM

If you want to do it well, you'll probably have to consider lift and downforce to the wings (depending on velocity and pressure) and variable gravity (depending on distance): g=G*Mearth/(radius+heightfromwater)^2 You should try implement windzones and high/low pressure zones

If you calculate all of this into separated vectors, you can finally sum all together and get the resulting force applied to the aircraft

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Realistic 2D flight physics? 0 Answers

Dynamic flight physics help. 0 Answers

How can I accelerate my Object to a maximum speed 1 Answer

Rotating an Arrow 2 Answers

Plane Mesh Collider doesn't stop Capsule ... sometimes. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges