Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 jt78 · Feb 28, 2012 at 05:13 PM · rigidbodyrtsangularvelocity

Roll based on turning speed

I'm working on a Space based top down RTS and I'm using bits of the SmoothLookAt script to make the ships rotate smoothly to 'look at' the point that was right clicked (everything's y position always = 0) - this works great.

Now I need to make the ships roll a bit as they turn (and level out as they start to fly straight again) much like real planes do in order to make a tight turn. My first thought was to do this every frame:

 shipObject.eulerAngles.z = rigidbody.angularVelocity.y * rollAmount;

I'll use rollAmount as a constant to make more agile ships roll more.

However, the SmoothLookAt code doesn't affect the rigidbody and actually freezes the rotation in the start function (I tried removing that but no luck) so angularVelocity.y is allways 0. Next I tried to do the same but calculate the angularVelocity myself using with the values of eulerAngles.y from the previous and current frames

 (current - previous) / Time.deltaTime

That sort of worked but the movement was extremely jerky and seemed to be flickering between a negative and positive rotation.

Any ideas of how to solve this - I'm a bit stuck? I'm looking for the kind of motion you get in Starcraft 2 air units if anyone's wondering what I mean.

The rolling won't affect the actual turning performance of the ship - it's just for show.

Thanks! :D

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

Answer by n8 · Feb 28, 2012 at 05:25 PM

Take a look at this script on the wiki. You will need to do some modifications to get it to be able to set a specific point to turn towards, but this will show you how to turn a rigidbody with banking

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

how to rotate a rigidbody to a point on a plane on mouse down 1 Answer

Gravity on a rotating platform 1 Answer

Aligning 2 Quaternions Using Torque 1 Answer

RigidBody AddForce not pushing rb to forward when adding angularVelocity 1 Answer

Angular Velocity is causing object to spin out of control 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