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 Clonkex · Apr 21, 2014 at 01:46 AM · javascriptrotate

How does Transform.Rotate actually work?

I've been trying to create a custom ragdoll system, which simply takes the jointed physics representation of the character and positions and rotates the bones of the visible character to match, but I've been having a lot of trouble.

I tried different methods of getting it all to work. I started out with this:

 BoneRoot.transform.rotation=Quaternion.identity;

But as per my other question, it still wasn't working, so I started experimenting. I discovered that if I did this:

 BoneRoot.transform.Rotate(-BoneRoot.transform.eulerAngles,Space.World);
 BoneRoot.transform.Rotate(Root.transform.eulerAngles-Root_RotOffset,Space.World);

It spun around wildly, which seems wrong. Then I found this post. Before seeing the accepted answer to that question, I believed that using Transform.Rotate with Space.World would rotate the object around World axes, regardless of the object's current angle, and using Space.Self would rotate from the object's current angle. After reading that post I'm not so sure. Does it rotate as though the pivot was at the world's centre or what?

All I want to do is set the angles of one object to that of another with an angle offset. Why is this so difficult?

My question is this: How does Transform.Rotate actually work? I.e., what are the specific differences and workings of Space.Self and Space.World?

Actually, what I really want to know is why doesn't this:

 BoneRoot.transform.Rotate(-BoneRoot.transform.eulerAngles,Space.World);

...set the angles to 0? Why not?? Why are rotations in Unity so complicated? I've never had this much trouble with rotations ever before!

Comment
Add comment · Show 13
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 robertbu · Apr 21, 2014 at 02:01 AM 0
Share

The pivot is the same but the axis is different. For example:

 transform.Rotate(0,speed * Time.deltaTime, 0, Space.World);

...rotates around the world up axis...Vector3.up. But:

 transform.Rotate(0,speed * Time.deltaTime, 0, Space.Self);

...rotates around the up axis of the object...transform.up.

avatar image xortrox · Apr 21, 2014 at 03:47 AM 0
Share

Did you try setting the rotation to root bone's rotation directly? transform.Rotate(x,y,z); will add x,y,z degrees per call.

avatar image Clonkex · Apr 21, 2014 at 12:07 PM 0
Share

@robertbu That's what I thought, but I'm still not sure if that's what I'm seeing.

avatar image Clonkex · Apr 21, 2014 at 12:08 PM 0
Share

@xortrox Yes. I tried BoneRoot.transform.rotation=Quaternion.Euler(Root.transform.eulerAngles-Root_RotOffset); but I still see the same thing. sigh ...yet more experimenting to do....WHY IS THIS SO DIFFICULT?!

avatar image Clonkex · Apr 21, 2014 at 02:22 PM 1
Share

@xortrox Indeed I have!! $$anonymous$$y problem is solved! :D Aren't I just brilliant? ;) Now, if only I'd been brilliant hours ago I could have saved myself all this bother... :P I'll post an answer to this question in a $$anonymous$$ute, but for a more detailed explanation of my solution, have a look at the answer to my other question.

Show more comments

1 Reply

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

Answer by Clonkex · Apr 21, 2014 at 02:26 PM

So it turns out a lot of my problems were caused by the fact that I didn't understand fully how Eulers are really annoying and bad. Now I do, and I have a solution to my root problem. See the answer to my other question for how I solved my problem.

To give a quick overview: Don't use Eulers. It turns out they really can be stupid and annoying. Now I understand why Quaternions are so good.

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 xortrox · Apr 21, 2014 at 02:27 PM 1
Share

Quaternion master race. Glad you figured it out.

avatar image Clonkex · Apr 21, 2014 at 02:28 PM 1
Share

@xortrox Thanks, me too :D

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

21 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 avatar image

Related Questions

Rotate towards target doesn't work properly (Quaternion.lerp) 1 Answer

Making a ball move towards the mouse? 1 Answer

Getting an object to rotate back to zero after key is released 2 Answers

change the rotation 1 Answer

Return to the origin of rotation 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