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
1
Question by Heratitan · Jan 09, 2011 at 02:37 AM · quaternionrotateslerpworldaxes

How do I rotate on World Axes with Quaternion.Slerp?

When I rotate my object using this script...

function RotateObject (thisTransform : Transform, degrees : Vector3, seconds : float) { if (rotatingNew) return; rotatingNew = true;

 var startRotation = thisTransform.rotation;
 var endRotation = thisTransform.rotation * Quaternion.Euler(degrees);
 var t = 0.0;
 var rate = 1.0/seconds;
 while (t < 1.0) {
     t += Time.deltaTime * rate;
     thisTransform.rotation = Quaternion.Slerp(startRotation, endRotation, t);
     yield;
 }

 rotatingNew = false;

}

...the object rotates on it's local axes instead of the world axes.

What is a fairly simple way to get this to rotate on World Axes?

Thanks in Advance =)

Comment
Add comment · Show 1
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 cregox · Oct 26, 2011 at 04:33 PM 0
Share

related: http://answers.unity3d.com/questions/171380/camera-relative-free-orbit.html

2 Replies

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

Answer by Jesse Anders · Jan 09, 2011 at 04:05 AM

Try changing this:

var endRotation = thisTransform.rotation * Quaternion.Euler(degrees);

To this:

var endRotation = Quaternion.Euler(degrees) * thisTransform.rotation;
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 Heratitan · Jan 09, 2011 at 04:36 AM 1
Share

Thank You! This was much simpler than I thought it would be.

avatar image toum · May 10, 2013 at 08:58 PM 0
Share

Could you explain what is the difference between these 2 orders?

avatar image
0

Answer by Kalu · Nov 19, 2011 at 05:44 PM

After lots of testing, the pins remain in place, but following the combination of rotation is complete, the cube undergoes some rotation along the Y axis that is manipulating the "wheel" of rotation Z or Y. And I can not understand where the problem. Here is the code used ..

 void Update () {
             if(switchControl == true && curTarget != null){
             if(curTarget.name == "RedR" || curTarget.name == "GreenR" || curTarget.name == "BlueR"){
                 Quaternion curPlanchTargetRot = Quaternion.Euler(angles);
                  curPlanche.transform.rotation = Quaternion.Slerp(curPlanche.transform.rotation, curPlanchTargetRot, 10f*Time.deltaTime);    
             }
         }
 
     void onMouseRotateDrag ()
     {
         float posInitX = initMousePosX;//position du curseur au moment du clic
         float posInitY = initMousePosY;
         float posCurX = Input.mousePosition.x;//position du curseur pendant le drag
         float posCurY = Input.mousePosition.y;
         
         differenceX = Mathf.Floor((posCurX-posInitX)/150);
         differenceY = Mathf.Floor((posCurY-posInitY)/150);
         curDifference = differenceX;
         if(Mathf.Abs(curDifference)<Mathf.Abs(differenceY)){//floor() valeur inf et ceil() valeur sup
         //    curDifference = differenceY;
         }
         
         if(curDifference != curApplyDifference){
             if(curTarget.name == "RedR"){ // axe X
                 angles.x = ((-curDifference*90) % 360);
                 curApplyDifference = curDifference;
             }else if(curTarget.name == "GreenR"){ // axe Y
                 angles.y = ((-curDifference*90) % 360);
                 curApplyDifference = curDifference;
             }else if(curTarget.name == "BlueR"){ // axe Z
                 angles.z = ((-curDifference*90) % 360);
                 curApplyDifference = curDifference;
             }
             posInitX = Input.mousePosition.x;
             posInitY = Input.mousePosition.y;
         }
     }


I need some help ... It's been three days I'm looking without much success

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 cregox · Nov 19, 2011 at 08:06 PM 0
Share

if you need some help, you should add this as a question. and if you wanted to call attention from ppl in this " thread ", then you could post comments. but above all, try to make your question clear. I can't understand what you're asking.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Quaternion Slerp is making me mad 2 Answers

Quaternion.slerp rotates instantly. 2 Answers

Quaternion.Slerp question, rotating back to original 1 Answer

360° Roation in one min 1 Answer

How to smoothly rotate an object on only two axes? 2 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