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 Lairinus · Dec 08, 2012 at 08:17 PM · quaternionsrotations

Quaternions rotating left and right, not forward and back

Hello.

I have a model. Imported said model to Unity. When instantiated, it is sideways, so I used the following code to rotate it:

 _crescentInstance.transform.rotation = new Quaternion(0, 180, 0, 0);

After hitting play and realizing how dumb it was to rotate something in the other direction, i changed its' rotation to 90. Nothing happened.

Then I changed the rotation to 270. Nothing happened.

For some reason it's only accepting rotations along the Y-axis of 180 and 0. Anything other than that does literally nothing.

I've re-imported the model, and I'm positive the base rotation for the game object is 0. I've even tried setting the instantiated angle to the Quaternion, and I have the same results.

Moreover i've tried the Rotate() function as well, and that too yields the same results.It's as if my model has no Y axis of 270 or 90.

Is this why in the documentation it said not to modify the X Y Z and W values unless you know exactly what you're doing?

Comment
Add comment · Show 3
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 fafase · Dec 08, 2012 at 08:18 PM 0
Share

You could read this article :http://unitygems.com/quaternions-rotations-part-1-c/

avatar image Lairinus · Dec 08, 2012 at 10:16 PM 0
Share

Thanks for that link!

Now I have it... somewhat working.. but its still kind of bleh.

What I have now is kind of a random effect...

`Vector3 rotateAngle = new Vector3(Camera.mainCamera.transform.forward.x, Camera.mainCamera.transform.forward.y * 90, Camera.mainCamera.transform.forward.z); _crescentInstance.transform.rotation = Quaternion.LookRotation(rotateAngle);`

By random effect, I literally mean that it works 25% of the time. Regardless of my direction in game, it will fire exactly how it's supposed to 25% of the time. The other times it will be facing towards me, to the left, to the right, and on a side.

I've noticed that it varies greater in direction depending on where I'm facing, but it still generally goes towards one direction

avatar image Saturnix · Dec 09, 2012 at 12:22 PM 0
Share

Stop struggling to make things more complicated that they are. Just do this: yourInstance.tranform.Rotate(Vector3.right * 90)

1 Reply

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

Answer by Saturnix · Dec 09, 2012 at 12:58 AM

Seems like you don't really understand what a Quaternion is (don't worry! I don't know it too! LOL).

To rotate an object you should use Transform.rotate or Quaternion.Lerp. I would recommend reading this page: http://docs.unity3d.com/Documentation/ScriptReference/Transform.Rotate.html

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 Lairinus · Dec 09, 2012 at 03:04 AM 0
Share

That just about answered it, thanks!

I've known about most of the other "math" concepts although Quaternions are brand new to me... As put in the other link that was sent, I don't doubt you'd have to be on a Stephen Hawking level to understand it completely. Oh well :(

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

11 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

Related Questions

Rotations, Quaternions and rigidbody physics 3 Answers

Can I use Quaternions to get from one point to another? 1 Answer

4 rotations WTF 1 Answer

Relative Rotations and Position calculation 2 Answers

My interpretation of Random.rotation and Random.rotationUniform. Right or wrong ? 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