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

People who like this

0 Show 0
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

  • Sort: 
avatar image
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

People who like this

0 Show 0 · 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

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta on June 13. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

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

2D 360 degress platformer example needed 0 Answers

In-Game Physical Joystick Questions 1 Answer

OnCollisionEnter problem 3 Answers

How do you turn on Ragdoll physics mid-game? 1 Answer

Trouble with car flipping on collision 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