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 ROMgame · Apr 11, 2014 at 07:37 AM · quaternionrotate objecteuler

Setting quaternion value around local z axis

In the Unity Editor sometimes when you rotate a object around the blue axis (i.e. the local Z axis using the blue circle) it modifies the local Y rotation of an object, sometimes it modifies the local Z rotation of the object. I understand that this is because of the way euler angles work where you can potentially have several euler angles for every one quaternion. It does however pose a problem for me.

I want to adjust an objects rotation to some value and then to set it's rotation around its local blue axis back to what it was previously. The problem is that simply storing the local Y rotation or local Z rotation and setting it back to that doesn't work because of the problem I highlighted in the first paragraph where Unity often flips between the two. So I guess my question is how do I solve this? How do I store the quaternion value around the local Z/blue axis and then set it back to it's previous value?

I've been stumped for days so any help would be much appreciated!

Thanks guys :)

Comment
Add comment · Show 2
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 sumeetkhobare · Apr 11, 2014 at 02:09 PM 0
Share

Never use:

 rotation.y = <some value>;


or

 rotation.z = <some value>;

Because rotation is quaternion having 4 parameters,viz.,x,y,z,w , ins$$anonymous$$d of 3,viz.,x,y,z. If you want to set your rotation to something, use:

 rotation = Quaternion.Euler(<some value>,<some value><some value>);


or

 rotation = Quaternion.EulerAngles(<some value>,<some value><some value>);

PS: the first uses Degrees and the second one uses Radians I guess, but not sure.. I use the First, becoz it gives me the results i want.

avatar image ROMgame · Apr 11, 2014 at 03:06 PM 0
Share

Thanks for the response! Presumably you'd have the same problem with that though, as with regular local Euler angles? i.e. transform.localEulerAngles?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by GravelFrog · Apr 11, 2014 at 04:00 PM

Create an empty GameObject and orient that to your desired default orientation. Add the game object you are manipulating as a child of that game object. Now you can manipulate the orientation of your child game object however you want without affecting the parent orientation. When your game runs it can simply manipulate the parent object to move it around or whatever you want to do with the object.

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 ROMgame · Apr 11, 2014 at 07:55 PM 0
Share

Sorry, maybe I didn't explain it quite right. The problem I'm having is with setting a euler angle on a specific axis back to it's previous value, i'm not sure if adding a parent would do anything to rectify that?

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

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

Related Questions

When applying a 90 degree rotation to Euler Angles, it is over/undershooting sometimes.. 2 Answers

360° Roation in one min 1 Answer

am I using degrees, radians, rotation or quaternion ? 2 Answers

Inverse Quaternion data from Kinect 1 Answer

Quaternion.Euler rotations don't add up 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