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 Laischen · Jul 02, 2014 at 06:21 PM · rotate

Could someone clarify RotateAround's function?

So in Scripting API you get this code example :

void RotateAround(Vector3 point, Vector3 axis, float angle);

What confuses me is the Vector3 axis, I don't see it making sense. Why vector 3?! I mean, If I want something to rotate around a point's x axis, why not just put x . Same goes for y and z. What does the value in that Vector3 mean? I mean, if I want some object to rotate around another with respect to the x axis, why would I put a float value in x's place? Why would a value be required? EDIT: I keep getting an object orbiting the other, but instead rotating as expected it just rotates about some point in empty space. I tried dozens of combinations to get it to simply rotate in circular motion, but it seems that it's not the RotateAround's function?

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 perchik · Jul 02, 2014 at 06:03 PM 0
Share

If you want it to rotate around the x axis, use Rotate() ins$$anonymous$$d.

RotateAround is used to rotate an object around an arbitrary axis.

2 Replies

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

Answer by K_Fi · Jul 02, 2014 at 06:48 PM

Having it as a Vector3 just allows it to do more than you need it to. It would be like getting a hammer with a claw on the back; even if you don't intend on removing nails, that's just how many hammers come.

What having a Vector3 axis lets you do is rotate the object around tilted axes, or ones that are not x, y or z. This would come in handy if you wanted to rotate around an object in one of it's local axes, as the function only takes axes in world space.

Example: I want to rotate a satellite around a planet's equator (Its y axis,) but the planet isn't upright in world coordinates. You can still call satelliteTransform.RotateAround(planetTransform.position, planetTransform.up, rotateDegrees), and the axis will be the planet's y axis (Which could be anything relative to world axes.)

In case you need them, world x, y and z axes in Vector3 values are just Vector3.right, Vector3.up and Vector3.forward. Also a note on putting a float into the x value, I'm pretty sure the parameter for the function only really cares about the normalized value as an axis is similar to a direction, so you can put in any non-zero positive float.

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 NoseKills · Jul 02, 2014 at 06:39 PM

Scripting API

This method could be used on the GameObject "Earth" to make it rotate around the sun (around a certain point other than the object's own pivot).

Why vector 3?! I mean, If I want something to rotate around a point's x axis, why not just put x . Same goes for y and z.

Because then you couldn't make it rotate around the axis Vector3(1, 1, 0) for example. There are an infinite amount of "axis" you can rotate around in a 3D space, not just the 3 that are aligned with the world coordinates.

Video of sphere at (1,0,0) rotating around axis (1,1,0)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Camera rotation around player while following. 6 Answers

How do I rotate object smoothly 3 Answers

How to have vertical and horizontal axis work at the same time 1 Answer

RotateAroundPivot rong offset 0 Answers

Help rotating an Object 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