• 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
3
Question by Jean-Fabre · Aug 18, 2010 at 08:00 AM · rotationtransformdirectioninvert

rotation relative to a transform

Hi,

I am lost with how to calculate the rotation relative to a transform.

While InverseTransformPoint works well to calculate a position relative to a transform, how do achieve the same process but for rotation?

in short:

I would like to know modelB rotation relative to modelA transform.

I tried InverseTransformDirection but it doesn't seem to work for me. How could I then express a rotation as a direction and vice-versa?

EDIT: let me rephrase: how do I compute manually the localRotation value when the model is actually not parented? That is, what is the localrotation of modelB as if it was parented to modelA? I am not trying to modify the actual localrotation of modelB, I just need to know it to inject it in the rotationTarget of a joint.

thanks for your help,

Jean

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
4
Best Answer

Answer by Aubrey Hesselgren · Aug 18, 2010 at 05:01 PM

To construct a Quaternion rotation from one orientation to another, you could try:

Quaternion rotationDelta = Quaternion.FromToRotation(modelA.transform.forward, modelB.transform.forward);

This means that if you multiplied modelA.transform.rotation by rotationDelta, you'd end up "turning" modelA's orientation to face the same direction as modelB's orientation. Hope that makes sense (and I hope I didn't get it wrong).

Basically, once you get that quaternion rotation is all about relativism, it kind of starts to make sense.

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 Jean-Fabre · Aug 19, 2010 at 08:06 AM 0
Share

ok, I think I understand what you mean, I am not able just yet to make it work, but trying.

avatar image Jean-Fabre · Aug 19, 2010 at 08:25 AM 0
Share

Ok I got it to work using your technic, thanks!

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to rotate instantated prefab without rotating it's local directions by javascript? 1 Answer

Moving an object with dependency of it's rotation 1 Answer

C#:"w" and "s" switch roles w/ transform.rotation of 180 0 Answers

Rotate the player toward a direction 0 Answers

Problem with Shooting Accuracy 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