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.
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…
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).
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.