- Home /
Question by
awoh · Aug 03, 2018 at 04:10 PM ·
rotatespeedrotatearound
How do I calculate the speed of an object that I move with RotateAround()?,How do I calculate the speed of an object that I move using RotateAround()?
private float speed = 50.0f;
transform.RotateAround(spawnTransform.position, Vector3.up, (Time.deltaTime * speed * direction));
How would I calculate the object's speed in meters/second from the code above?
Comment
Answer by Bunny83 · Aug 03, 2018 at 04:46 PM
You just rotate at a certain angular speed. Just convert the angle / second into radians / second so you get the distance traveled on the unit circle. Then just multiply by your "radius" of your circular motion and you get the distance traveled along the circular path per second:
concrete it would look like this:
float angularSpeed = speed * direction * Mathf.Deg2Rad; // rad/sec
float travelSpeed = angularSpeed * Vector3.Distance(transform.position, spawnTransform.position);