- Home /
RotateAround explanation.
Can anyone explain me what is and how to use third parameter in RotateAround (angle).
How I think RotateAround works.
transform.RotateAround (target.position, new Vector3 (0, 1, 0), 90 * Time.deltaTime);
First parameter is the position around which we want the sphere B to rotate, so in my case it will be position of my Cube.
Second parameter is the axis around which it should rotate. Since it is (0,1,0), it will rotate around Y axis.
Third parameter is something I don't know and/or understand. What is angle? If it is rotating then what is the work of angle. Even if I put 180 instead of 90, there is visually no difference.
var angle =5F;
transform.RotateAround(Vector3.zero, new Vector3(0F,1F,0F), angle);
it seems that the angle acts more like a speed increment-er rather that getting the angle based on the targets position
Answer by Bunny83 · Dec 13, 2014 at 05:38 PM
RotateAround does one single rotation around the given center point and axis by the amount specified in the third parameter. So if you call this once:
transform.RotateAround (target.position, new Vector3 (0, 1, 0), 90);
It would rotate the sphere around the cube by 90°. However if you call this method in Update, which means it's being called each frame (at 60fps == 60 times per second) rotating by 90° wouldn't make much sense as each frame it would be rotated 90°. So the given parameter specifies the speed how fast it rotates. Since the frame rate can vary you would get different speeds on different platforms / PCs /... By multiplying with Time.deltaTime you make the speed frame independent and the speed becomes time-dependent (like we usually measure speed, distance or angle in a certain amount of time).
90*Time.deltaTime
This actually returns a fractional angle which is modified for the current framerate so if you accumulate those fractions they will add up to 90° after 1 second. So you have a rotation speed of one (360°) rotation in 4 seconds or 15 rpm.
When you use 180 instead of 90 it should rotate twice as fast.
Answer by chelder · Jun 10, 2016 at 03:04 PM
It was hard to understand how it works. The Unity documentation did not help me much (I asked about what confused me here)! I have drawn a picture I hope it helps to visualice to you all:
So if you change the angle, you will change the position within the green drawn circle...
I don't know what you tried tro link here, but it isn't a documentation page. ;)
The documentation link would be:
http://docs.unity3d.com/ScriptReference/Transform.RotateAround.html
Your answer
Follow this Question
Related Questions
easing a rotation of ROTATE AROUND 1 Answer
rotate around character 1 Answer
Character Rotation Now Matching GameObject's Local Rotation 0 Answers
Rotate Around Planet with Spaceship Face Set on Path 1 Answer
Rotate within range 1 Answer