What the angle argument means in the Transform.RotateAround function?
The declaration of the RotateAround function is:
public void RotateAround(Vector3 point, Vector3 axis, float angle);
Let's say we have a GameObjectA in the position A with the above script attached, and another GameObjectB in the position B:
float speed = 10f;
void Update () {
transform.RotateAround (B, Vector3.up, speed * Time.deltaTime);
}
So if I understood well, the GameObjectA will rotate around the GameObjectB. The GameObjectA will pass by its original position once per loop. The rotation will be around the Vector.up axis. The rotation will be at the speed 10. However the declaration of the argument says that argument is to enter the angle, not the speed. Is it a mistake? Am I confused with something about maths or English?
UPDATE: I have drawn a picture that should help you a lot to understand how RotateAround work. See here the picture: http://answers.unity3d.com/answers/1200748/view.html
Answer by Jessespike · May 05, 2016 at 06:12 PM
In the snippet, the amount to rotate (angle) is controlled by time * speed per frame. I think you may be overthinking it. It's just using time as the amount to rotate per frame. speed * time is the angle for that frame.
Huh? No the documentation of RotateAround is perfectly fine. It's just your understanding that seems to be twisted in a weird way. RotateAround performs a single relative rotation by the amount specified in the last parameter. So if you pass "45" degrees and call the method one time the object will advance on the circle by 45°. Things like speed doesn't have anything to do with that method definition.
If you use that method every frame to perform a continous rotation then you introduce speed in the sense of how much you move per frame or per second( if you multiply by Time.deltaTime). It seems you have trouble understanding Time.deltaTime so you might want read up on deltaTime and try to understand how and why it works. You also might want to read my answer on your linked question carefully.
I finally got it. Thank you. Anyway, I think your explanations and my picture should help other people too :)
Your answer
Follow this Question
Related Questions
How do I rotate an object around around another, following mouse position and facing it? 0 Answers
Manual RotateAround 0 Answers
Is there a RotateAround functionality for Rigidbody 2D's? 1 Answer
How to Transform.Rotate Around with the rotation of the controller right stick 0 Answers
Deformation of child object when rotating around a rotatable parent object 0 Answers