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 wlad_s · Jan 15, 2013 at 08:05 PM · quaternionrotatetowards360

Quaternion.RotateTowards to rotate beyond 360?

Hi,

This will probably sound noobish :) But why Quaternion.RotateTowards won't rotate beyond 360 degrees? Actually, even if I make the target 320 degrees, it will not rotate to 320 degrees but will go in the opposite direction to rotate to -40 degrees.

I understand what's happening but I'm curious if this is an issue with quaternion rotations in general or with RotateTowards?

 function Update () {
     
     var rotation : Quaternion;
     
     rotation.eulerAngles = Vector3(0, 320, 0);
     
     transform.rotation = Quaternion.RotateTowards(transform.rotation, rotation, 20*Time.deltaTime);
 
 }
Comment
Add comment · Show 3
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 Jessy · Jan 15, 2013 at 08:15 PM 0
Share

That's the same thing.

avatar image wlad_s · Jan 15, 2013 at 08:17 PM 0
Share

Yes, I know it's the same thing in the end, but what if I'd want my object to rotate five full circles? It would stop at the same rotation, of course, but the player would see it rotate five times over some period of time.

avatar image robertbu · Jan 15, 2013 at 09:30 PM 0
Share

If you know the axis of rotation, there a few ways to solve this problem. Calculate the degrees per second at the start and use Transform.RotateAround() is one way.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by markfm · Jan 15, 2013 at 08:50 PM

The only realistic way to do this would be to check if the rotational angle has reached 359 degrees. You need to understand that there is between -180 and 180. Therefore to make it go around 5 times you have two options.

  1. Use the animator and animate it going round 5 times.

    var speed = 10;

    function Update {

      if (transform.rotate.y => 90)
         {
          transform.Rotate(Vector3.up * Time.deltaTime * speed);
         }
     
         // do whatever when the planes move and repeat the above. 
    
    

Hope this helps.Code above is untested.

Comment
Add comment · Show 2 · 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 wlad_s · Jan 15, 2013 at 08:58 PM 0
Share

Well, it would take too much space if I was going into details on what I was trying to achieve. In short, I wanted two airplanes to rotate 90degCV to their sides when passing one another and then completing the loop to 360 and do a full360 again when they pass each other. I did the first half (90degrees one), they do rotate relative to their distance, and I did write the remaining 2x360deg one, but when they pass each other, they just return to 0deg, going the CCV way, not continuing the started CV pirouette in CV direction. Anyway, I just achieved this with animation states. Thank you for commenting. I like doing these things through math, not animations, but it seems impossible because of this 360=0 convention.

avatar image markfm · Jan 15, 2013 at 09:07 PM 0
Share

Edited above.

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

11 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

Related Questions

Doing 2D only rotation using FromToRotation + RotateTowards 0 Answers

Convert Quaternion to Eulerangles 2 Answers

Quaternion.RotateTowards with 3 several rotation target 0 Answers

2D 360 degress platformer example needed 0 Answers

to rotate along z axis 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