Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 sbsmith · Nov 07, 2016 at 08:01 PM · transformquaterniongimbal-lock

Gimbal Lock with Quaternions

What is the difference between these

 1. ctrl.spawnedObject.transform.localRotation *= Quaternion.Euler( 0f, 0f, 90f );
 2. ctrl.spawnedObject.transform.Rotate( new Vector3( 0f, 0f, 90f ), Space.Self );
 3. ctrl.spawnedObject.transform.localRotation *= Quaternion.AngleAxis( 90f, Vector3.forward );

and this?

 Vector3 worldVec = ctrl.transform.localToWorldMatrix.MultiplyVector( Vector3.back );
 ctrl.spawnedObject.transform.RotateAround( ctrl.spawnedObject.transform.position, worldVec, 90f );

I have an object inside of a container. The object is spawned as prefab with a default Euler rotation of (90, 0, 180). I would like to rotate the object on the local Z axis. However, all rotations listed in the first code block result in a rotation on the local Y axis.

The second code block performs the expected rotation around the local Z axis.

I'd like to better understand why.

In the editor, I can see that the block is gimbal locked (rotating the Y, and Z parameters rotate the object on the Y axis) and the block's transform.forward reads as Euler (0, -1, 0).

I created an example project here: https://github.com/lrgsteven/help_unity_gimbal

Thanks for your help.

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 elenzil · Nov 07, 2016 at 09:05 PM 1
Share

any of those approaches should work.

here's a simple demo project showing modifying localRotation via euler-angles.

--> are you sure the code is executing as you expect ? ie, are those lines actually executing ? put in some logging.

--> is the scene wired to the controller correctly ?

--> cubes are notoriously symmetrical under 90º rotations. are you sure the cube's not rotating ? I'd suggest using a less symmetrical model. I've often seen the letter "F" used.

avatar image sbsmith elenzil · Nov 07, 2016 at 09:17 PM 0
Share

Thanks for the reply!

a) I've stepped through the code with my debugger to check values.

b) As far as I can tell.

c) I will change the name of the cube in the example. It's actually a model of a block with distinct geometry.

It is heartening to hear that my approach seems correct and that something else may be the problem. I'll try to build a more simple example and report back within a couple of days. For now, I'm actually swamped with other work and this got bumped way down in priority.

avatar image sbsmith elenzil · Nov 08, 2016 at 02:19 AM 0
Share

I checked out the project you made and everything you're doing makes complete sense to me. I've rephrased the question because now I'd like to understand why the other stuff does not work.

0 Replies

· Add your reply
  • Sort: 

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

64 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 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 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

Quaternion rotation issue 1 Answer

Clarifying the ambiguities of rotation in Unity 1 Answer

How to make Y-Axis face away from a position? 2 Answers

Write a C# script to record GameObject rotation? 4 Answers

How i can equal 2 Tranform Rotations? 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