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 Befall · Jan 19, 2012 at 07:19 AM · rotationquaternioncombine

Combining two Quaternion Slerps on an object

Hey all,

So, I have a game that requires rotation around a pipe on four cardinal axes, as well as turning along curved tracks. What I have currently that work independently are two Quaternion.Slerps, seen here:

 // Turns transform around pipe
 transform.rotation = Quaternion.Slerp(prevTurn, nextTurn, t);
 // Turns transform as it hits curved sections
 transform.rotation = Quaternion.Slerp(prevTwist, nextTwist, tPos);

So, these both work by themselves, but any combination I've tried has failed. But I need the object to be able to curve along these pipes and spin around them simultaneously. Any ideas?

Thanks! :)

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
0

Answer by Kryptos · Jan 19, 2012 at 08:59 AM

Quaternions can be combined with *operator, according to the documentation (http://unity3d.com/support/documentation/ScriptReference/Quaternion-operator_multiply.html).

So you can do for instance:

 // Turns transform around pipe
 Quaternion qPipe = Quaternion.Slerp(prevTurn, nextTurn, t);
 // Turns transform as it hits curved sections
 Quaternion qTurn = Quaternion.Slerp(prevTwist, nextTwist, tPos);

 transform.rotation = qTurn*qPipe;

Not that qTurn*qPipe and qPipe*qTurn will create different combination. You may need to try with one or the other.

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 Befall · Jan 19, 2012 at 09:41 AM 0
Share

I've tried every form of this that I could, and it never works out satisfactorily. It never ends up with my character on cardinal directions. I always end up with awful, mixed up rotations at the end of the pipe sections.

avatar image Kryptos · Jan 19, 2012 at 10:05 AM 0
Share

Well then, the problem is no the quaternions but maybe your t and tPos parameters.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

how to combine 2 quaternion components? 2 Answers

Two scripts rotating the same object 1 Answer

combine / convert rotations (Quaternion and Vector3) 1 Answer

[2D] Rotations become tighter the further left they are? 1 Answer

Transform a Vector by a Quaternion 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