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
1
Question by easilyBaffled · Sep 22, 2012 at 06:43 PM · rotationrotaterotatearound

Can't Rotate around just Y Axis

I have an empty object rotating inside of the ball, and rotating the ball itself. I am trying to rotate the empty object around it's Y axis to turn the ball. I have tried :

 down.Rotate(Vector3.up*-10.36997);
 
 
 down.Rotate(0,-10.36997,0);
 
 
 down.rotation.y -= 10.36997; //this one just does unspeakable things to the entire rotation
 
 down.RotateAround(down.position, down.up, -10.36997);

All of these should rotate around the Y axis, ONLY, right? Well, no, not so much. It rotates around the Y axis properly but it also affects the X and Z rotation, anyone know why?

Comment
Add comment · Show 1
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 MountDoomTeam · Sep 22, 2012 at 06:48 PM 0
Share

sry i dont understand what you want to do. you have 2 objects inside of each other. are they parented? a ball... give us abit of background about the ball. you want the to rotate independantly, one one way and another the other way?

the sound like they are both game objects, if you can make one rotate, then you should be able to make a reference to the other and put down.rotate in front of the other object also. they are the same game entity, a game object.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by aldonaletto · Sep 22, 2012 at 07:06 PM

If you're talking about the X and Z fields you can see in the Inspector/Rotation, don't mind: Unity shows localEulerAngles in the Rotation fields. This property doesn't actually exist as a variable - it's calculated on the fly based on transform.rotation. Since there are several XYZ combinations equivalent to a given rotation, Unity chooses one of them based on an internal and totally obscure policy. This may result in weird changes in these fields when certain points are crossed - but the weird values returned are valid and equivalent to the current rotation.
The first two instructions should do the job ok, the 3rd is a complete nonsense (rotation is a quaternion - don't mess with its components!) and the 4th is a complicated and time consuming way to do what you want.
Anyway, if you're experiencing problems like the Y local axis being tilted after some time, keep your own localEulerAngles, rotate them mathematically and update the object's localEulerAngles, like this:

private var euler0: Vector3;

function Start(){ euler0 = down.localEulerAngles; }

// to rotate the object: // rotate the angle mathematically in modulo 360: euler0.y = (euler0.y - 10.36997) % 360; down.localEulerAngles = euler0; // update the actual rotation

The rotation must be kept in modulo 360, or weird things may happen when out of range values are reached!
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

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

Rotate object in the direction where it is going 1 Answer

rotate object around another object 1:1 1 Answer

Smooth Camera Rotation relative to World [SOLVED] 1 Answer

instant rotate an object 3 Answers

How do I rotate on a new pivot point with RotateAround? 2 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