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 FlameJackal · Jun 26, 2013 at 06:45 PM · transformrotatecubesphererotatearound

Why am I getting 2 different results with RotateAround? Trying to move cubes on surface of sphere.

I have the following line in a script on cubes that are spawned as children on the surface of a sphere. transform.RotateAround (Vector3.zero, -Vector3.up, -5);

It works relatively well however I want the cubes to rotate around an axis parallel to their forward vector that goes through the center of the sphere they are on. I tried the following

transform.RotateAround (Vector3.zero, transform.forward, 5);

This makes the cubes rotate about an axis going through THEIR center and doesn't move them along the sphere. With the second approach I feel that the behavior of RotateAround is somehow changing. Regardless of where the cube is on the sphere they are only rotating about their own axes.

Am I missing something about how this works? Please let me know if I can clarify.

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

1 Reply

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

Answer by robertbu · Jun 26, 2013 at 07:08 PM

A couple of things. Position matters. If you place your block on top of the sphere to start, then your rotation should work. Next, if the sphere is not rotated during the game, consider using Vector3.forward instead of transorm.forward. Also you should be multiplying by Time.deltaTime to keep your code frame rate independent.

 transform.RotateAround (Vector3.zero, Vector.forward, 50 * Time.deltaTime);
Comment
Add comment · Show 3 · 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 FlameJackal · Jun 26, 2013 at 08:24 PM 0
Share

Thanks for bringing up the sphere rotation - I should have mentioned that. The sphere is constantly rotating about its x axis. The blocks are spawned at 0,0,1 (the top of the z side of the cube). This code is also executed on button press. I want all the cubes to do the rotation when the button is pressed. Because of this I thought that I didn't need Time.deltatime, IE all the blocks rotate 5 degrees to the right on the sphere when I press D. Thanks a lot for the answer - this was my first UnityAnswers question and I'm surprised that it was addressed so quickly.

avatar image FlameJackal · Jun 26, 2013 at 08:26 PM 0
Share

the blocks spawn at 0,0,1 (z side of the sphere) and you mentioned an important point - the sphere that the blocks rest on is constantly rotating about its x axis. This line of code is called on button press and isn't executing every frame so I didn't think I needed Time.deltatime. I guess the important part is that the sphere is always rotating - that's probably where the issues is co$$anonymous$$g from.

avatar image robertbu · Jun 27, 2013 at 12:27 AM 0
Share

If the sphere is rotating, and you are using transform.forward to rotate around, then you want to use transform.up as the place to instantiate your blocks. If the sphere has no rotation, and you spawn at (0,0,1), and you use Vector3.forward, you will get the behavior you describe above where the block appears to rotate around its own axis..

If you are doing an immediate rotation of 5 degrees on a single event, then you are right that you don't need to use Time.deltaTime.

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

15 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

Related Questions

Rotate Around an Object using a different pivot point? 0 Answers

Apply torque/force to rotate an object around a fixed point 1 Answer

Quick Shortcuts for Rotation 0 Answers

RotateAround x degrees over y time 1 Answer

transform RotateAround 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