• 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 Notter · May 03, 2015 at 04:07 PM · physicsflight sim

how to change flight direction in a Bird sim

Hi, i new to physics in unity, and i kinda dove into something that might be a bit tricky to implement.

i want to make a player controlled bird, that's able to "flap" in order to push itself forward and up, and also be able to bank left/right to turn.

I've managed to do that so far, but i have an issue that it's very unrealistic. meaning: the bird flies forward, then i turn the Y-axis to turn to the side, but i keep flying in my previous direction.

i understand why this happens, but i want to be able to make a smooth turn / smooth change of direction.

so far i've done this:

 private void FixedUpdate()
     {        
         if (Input.GetButtonUp("Flap"))
         {
             rb.AddForce(transform.up * 20, ForceMode.Impulse);
             rb.AddForce(transform.forward * Thrust, ForceMode.Impulse);
         }
         else if (Input.GetButton("Flap"))
         {
             rb.AddForce(transform.up * 85);
         }
 
         AddRotation();
     }

    private void AddRotation()
     {
         Quaternion AddRot = Quaternion.identity;
         float roll = 0;
         float pitch = 0;
         float yaw = 0;
 
         roll = Input.GetAxis("Roll") * (Time.fixedDeltaTime * RotationSpeed);
         pitch = Input.GetAxis("Pitch") * (Time.fixedDeltaTime * RotationSpeed);
         yaw = Input.GetAxis("Yaw") * (Time.fixedDeltaTime * RotationSpeed);
 
         AddRot.eulerAngles = new Vector3(-pitch, yaw, -roll);
         rb.rotation *= AddRot;
     }


So far I've tried playing around with Drag, but that will just make my bird stop still in the air. I've tried changing velocity, but then it will just move in the air like a plane.

If i look at a game like this: http://www.unity3dgames.net/fly-like-a-bird-3_play.html I can see the bird changing it's momentum immediately while turning

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Dave-Hampson · May 04, 2015 at 08:07 AM

Maybe you could apply a "lift" Force perpendicular to the wings, so that when the wings turn the force pushes/rotates in that direction too.

Kind of like your "flap" force but running all the time, and balanced against gravity.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

20 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

Related Questions

In-Game Physical Joystick Questions 1 Answer

2D 360 degress platformer example needed 0 Answers

how to stop mesh entering another mesh, both with colliders 3 Answers

Does AddForce use Time.deltaTime or TIme.fixedDeltaTime or it depends on whether it is being used in Update() or fixedUpdate()? 2 Answers

Rendering Wireframes of FixedJoints 0 Answers


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