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 The_Ultraviolence · May 11, 2011 at 06:19 PM · rotationtransformeulerangles

unexpected axis values when a sphere rotates 360 degrees around a game object

I'm experiencing some weird behavior that I cannot explain. Im using an empty game object as a central point ("origin") where a second game object (a sphere) revolves around it, completely. This is meant to mimic the rotation of the sun, in a full day-night cycle.

Firstly, I would have expected that the rotational (transform.eulerAngles.y) value would change along the y-axis as this game object moves/rotates around the origin. Instead, it is the (transform.eulerAngles.x) that is changing. I can't explain why?

Secondly, more importantly, I would have expected the transform.eulerAngles.x to return the degrees of 0-359. Instead, once the sphere hits 90 degrees, the transform.eulerAngles.y and transform.eulerAngles.z values flip from being "0" - to each being "180"... and the transform.eulerAngles.x decrements itself from 90 back to 0 again (where it really should have been 180 degrees).

I expected the sphere to increment beyond 90 degrees, and did not expect the other axis values to flip to 180 each.

I know I'm doing something completely wrong here. But I cannot figure out what? Does anyone have any suggestions? Answers?

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 Michael 16 · May 11, 2011 at 06:34 PM 0
Share

You use a code or an animation for that?

avatar image The_Ultraviolence · May 11, 2011 at 07:30 PM 0
Share

I am using c# scripting.

avatar image flaviusxvii · May 11, 2011 at 08:12 PM 1
Share

Your description makes no sense. There is a good change you are having a stroke at this very moment (an hour ago). Call an ambulance.

Or post some code or something. Honestly, I have no clue what you're blathering about.

1 Reply

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

Answer by Owen-Reynolds · May 11, 2011 at 08:55 PM

Some code would help -- are you using transform.Rotate(1,0,0); if so, then, yes, you are rotating around x.

The flipping numbers are probably classic gimbal lockish stuff. Some directions have multiple ways of rotating to get them. For example, a 180 degree y-spin is the same as a 180 z followed by a 180 on x. If you look, Rotate does the rotations in Local z, then x then y. So, if you get turned on your side, then a y rotation really is an x rotate (in world, non-local, space.)

Quaternions were invented (really, stolen) to solve this, but they are tricky to learn.

If the spin works, just ignore the numbers. It's a little like how Unity snaps -10 degrees to 350 degrees. If it's causing problems, try directly setting angles. Create Vector3 Angles; and set Angles.x, Angles.y, Angles.z yourself (add 1 degree, or something) and set with with transform.eulerAngles = Angles;. That will prevent Unity from snapping them around (it still will, but not on your copy.)

Comment
Add comment · Show 2 · 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 The_Ultraviolence · May 12, 2011 at 01:24 AM 0
Share

You are correct Owen. The piece of code responsible for the movement and rotation is as follows:

Sphere[0].transform.RotateAround(AroundThis[0].position, Vector3.right, (Time.deltaTime * _multiplier));

So, as I understand now, the rotation occurs on the x-axis.

avatar image Owen-Reynolds · May 12, 2011 at 01:11 PM 0
Share

Common mistake...seems like "right" says to rotate right, but really means to rotate around an L/R stick. $$anonymous$$ost plp would use Rotate for an x,y or z spin. RotateAround is primarily special cases: you have some odd axis of spin or don't want to rotate on your own (0,0,0)

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

EulerAngles value as floating point 1 Answer

20 is not equal to 20 while using Vector3.MoveTowards 2 Answers

How to Rotate a CUBE by 90 Degrees when a key is pressed 1 Answer

"Object reference not set to an instance of an Object" 0 Answers

Bone Not Rotating? 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