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 /
This question was closed Jul 08, 2014 at 06:48 PM by pheash for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by pheash · Jun 21, 2012 at 09:37 PM · quaternionrotatetowards

RotateTowards, Quaternion conditional, do Quaternions have 2 values?

Sorry for yet another quaternion question. basically i want to know if there are 2 quaternion values that are the same, like an opposite. I am using RotateTowards and then an if to check whether it has finished rotating. The problem is that printing the angle that its supposed to end at is different than my actual angle, even though rotateTowards seems to have finished. here are the prints that i get: Expected Angle : (0.0,0.9,0.0,-0.4) After RotateTowards : (0.0,-0.9,0.0,0.4) the If statement is never getting true since some of the values are inverted but they still seem to be correct. how can i make this work? or is there a better way to check for when Rotate Towards is finished? here is some of my code:

 weaponBarrel.transform.rotation = Quaternion.RotateTowards(weaponBarrel.transform.rotation,barrelRot,barrelRotateSpeed*Time.deltaTime);
 if(weaponBarrel.transform.rotation==barrelRot){
     fire=true;
 }

see how barrelRot is in the if statement and the rotateTowards statement...

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

  • Sort: 
avatar image
2
Best Answer

Answer by Owen-Reynolds · Jun 21, 2012 at 10:38 PM

Yes. Quaternions are a "double cover," which means there are two ways to write each value.

To check close enough, on a rotation, I usually check Quaternion.Angle(current, target)<small, which is probably very inefficient.

Supposedly (never tried this,) even though dot product isn't the same for Quats, you can check if Abs(Quaternion.Dot(A,B)) is close to 1, you have the same angle. (In other words, dot product is 1, or -1 since you got the "other" version of the angle.)

Comment
Add comment · Show 1 · 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 pheash · Jun 22, 2012 at 05:53 AM 0
Share

hey Owen, thanks for your answers. I am using the Quaternion.Angle

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Quaternion.RotateTowards() immediately snaps to target rotation 1 Answer

How to rotate towards the mouse on one axis while snapping 0 Answers

Object rotate to target in 2D? Not working properly. 0 Answers

Doing 2D only rotation using FromToRotation + RotateTowards 0 Answers

Quaternion.RotateTowards with 3 several rotation target 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