Rigidbody: Linear motion to Circular motion
Hey there!
So I am trying to figure out how I can go from my object moving in a straight line to have it rotate in a circle around a specific point at a set distance.
Right now, I have something working but there are a lot of weird edge cases I need to cover to get the result I want, so I am looking for a more robust solution. Basically The object has a a constant velocity on it in a specific direction (via rigidbody.addForce). When I press space, I use transform.rotateAround to move the object around a specific point in a circle.
The problem is that for rotateAround, I have to figure out how to set the angle (either positive or negative) to get the object rotating in the correct direction (either clockwise or counter-clockwise). I've spent a ton of time thinking about it and I can't figure out a good solution to get the right rotation direction every time.
Any ideas? Right now I think it would be good to use vectors since I already have a direction vector for the linear velocity applied through addForce. I have messed around with Quaternion.AngleAxis to change the angle of the direction vector applied to the object, but I am not sure how to calculate the angle to get the object to rotate around in the right direction, and along a perfect circle with a fixed radius. Honestly, I don't know that it is even possible.
In any case, I could use some help, so anything you can provide is greatly appreciated.