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 Posthuman-Wizard · Feb 03, 2013 at 05:56 PM · rotationtransformquaternionrotaterotating

Rotation not working

Hello all. I'm trying to rotate an object through code as I would using the "rotate" tool in the editor, but for whatever reason, the object seems to keep rotating along the global axis (Whereas I need it in the same spot, just turned to the side).

I've used obj.transform.Rotate(), obj.transform.RotateAround(), obj.transform.RotateAroundLocal(), using both Vector3.Up and obj.transform.up as parameters, and I've had the same misfortune trying to manipulate the obj.transform.rotation, obj.transform.localRotation, obj.transform.eulerAngles, and obj.transform.localEulerAngles, all not working as desired: the object still appears to be rotating along the global Y axis, as opposed to the local. For reference, what I am trying to do is explained in the attached image. Any help would be greatly appreciated.alt text

demonstrationofproblem.png (24.3 kB)
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 whydoidoit · Feb 03, 2013 at 06:26 PM 0
Share

Is the object a child of another object? Is it modelled to be centralised at 0,0,0?

avatar image Posthuman-Wizard · Feb 03, 2013 at 06:31 PM 0
Share

No to the first, and yes to the second.

avatar image whydoidoit · Feb 03, 2013 at 06:41 PM 0
Share

And what do you do in the editor to make it change the way you want?

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by lollornr · Feb 03, 2013 at 08:20 PM

Manipulating transorm.rotation is a bad idea because you have to work with a quaternion, not a Vector3. Maybe the origin of the object that you try to rotate isn't the origin of the geometry!

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 whydoidoit · Feb 03, 2013 at 08:35 PM 0
Share

There's nothing wrong with working with Quaternions ;)

avatar image
0

Answer by robertbu · Feb 03, 2013 at 07:58 PM

Are you sure about your diagrams? I would expect the arrow to point in the opposite direction on the results panel of "What is happening." If your diagram is correct, then you likely need to post some source code so that folks take a take a look.

Assume the arrow is backwards in the diagram, I recommend you replace the arrow with Unity's build-in cube object and then run your code. If the cube suffers the same problem, then the problem is likely a parent/child issue of some sort. If the cube does not suffer the same problem, then your issue is with the arrow object and likely a problem with centralization as @whydoitdoit suggested above. Note you can adjust for a model not being centralized by making the model a child and empty game object and adjusting for the offset.

Comment
Add comment · 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
0

Answer by sparkzbarca · Feb 04, 2013 at 08:37 AM

if your trying to rotate an object in the manner in which you would rotate a clock hand you dont want to rotate on the y axis you want to rotate on the forward axis.

if you'll notice with a clock the axis of rotation is the pin that goes through the middle of it. rotating is a twisting action along an axis. So if you think of a clock with the pin you need that pin axis.

Comment
Add comment · 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

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

12 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

Related Questions

Rotation Jumping values (0 to 180) 1 Answer

How to instantiate on custom rotation? 1 Answer

Rotate object to where aiming 1 Answer

Player character X rotation going haywire on game start 1 Answer

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