- Home /
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?
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.
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.
Answer by NoseKills · Jul 02, 2014 at 06:39 PM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220613153026im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
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