I am currently using
transform.RotateAround(transform.position, Vector3.forward, degreesPerSecond * Time.deltaTime)
to make an object rotate around another object. This works well, but I want to make the object stop rotating around and instead move in a certain direction at the same speed that it was rotating. However, I can not figure out how to convert the degreesPerSecond
into a directional speed.
My goal is to have something like this:
if(rotating) {
transform.RotateAround(transform.position, Vector3.forward, degreesPerSecond * Time.deltaTime)
} else {
transform.position += transform.right * DegreesToDirectionalSpeed(degreesPerSecond ) * Time.deltaTime;
}
float DegreesToDirectionalSpeed(int degrees) {
// Code that I don't know goes here
}
Any tips on how to achieve this?