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 LifeSizeDeity · Jan 13, 2011 at 11:47 PM · quaternionrotateslerp

Quaternion Slerp is making me mad

Quaternion initial = Quaternion(90f, 180f, 0f, 1f); Quaternion ending = Quaternion(90f, 263.3441f, 0f, 1f);

float cameraPos = Mathf.SmoothStep(0.0f, 1.0f, (Time.time - startTime) / someTime);

cardCamera.transform.rotation = Quaternion.Slerp(initial,ending, cameraPos);

This will not rotate my camera. It is supposed to rotate my camera smoothly over a period of time from a starting to ending rotation, but it just snaps the camera to a strange rotation. The only thing I can think of is the construction of the Quaternion is done in degrees. It's been years since I've mess with this stuff so please assume I have the grasp of an infant.

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

2 Replies

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

Answer by DaveA · Jan 13, 2011 at 11:56 PM

Quats are x,y,z,w, where x,y,z define an 'axis' and w is related to the angle around that axis. That axis should also be normalized, so none of those numbers should be greater than one. Look at this reference to see what you can find: http://unity3d.com/support/documentation/ScriptReference/Quaternion.html

But you may want to instead use RotateTowards() on your camera.

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 LifeSizeDeity · Jan 14, 2011 at 12:31 AM 0
Share

The only reason I'm not using RotateTowards() is because I'm currently using a Lerp() to move the camera, so I really wanted to be able to use the same 0 - 1 variable to interpolate.

float cameraPos = $$anonymous$$athf.SmoothStep(0.0f, 1.0f, (Time.time - startTime) / someTime);

avatar image
1
Best Answer

Answer by Jesse Anders · Jan 14, 2011 at 12:09 AM

To elaborate a bit, you don't want to construct quaternions manually that way, and the elements are not angles. DaveA is close with his description, except that the x, y, and z elements, while being parallel to the (unit-length) axis of rotation, won't necessarily be unit length. (The quaternion itself, however, will be unit length.)

If you want to create a quaternion from a set of Euler angles, however, you can write:

Quaternion initial = Quaternion.Euler(90f, 180f, 0f);
Comment
Add comment · Show 3 · 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 DaveA · Jan 14, 2011 at 12:18 AM 0
Share

I stand corrected, thank you

avatar image LifeSizeDeity · Jan 14, 2011 at 12:36 AM 0
Share

Quaternion [] cameraRotation = { new Quaternion.Euler(90f, 180f, 0f), //DEFAULT }

This is giving me an error. It says the nested type 'Euler' does not exist in the type 'UnityEngine.Quaternion'

Any idea?

avatar image LifeSizeDeity · Jan 14, 2011 at 12:58 AM 0
Share

Never$$anonymous$$d, thanks for the example

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

No one has followed this question yet.

Related Questions

How to smoothly rotate an object on only two axes? 2 Answers

Doesn't Add Rotation Over 180 2 Answers

This can't be impossible or? Rotate (flip) smoothly from one point to endpoint on mouseclick. 3 Answers

Quaternion.Slerp only one axis? 1 Answer

Quaternion.Slerp problem... 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