Hello!
I’ve got a fairly complex scenario where I need to update an objects rotation speed and clockwise/counter-clockwise direction. The rotation is just about the Z axis as I’ve scripted my game to be 2D in the X and Y. I’m not using gravity but have created my own custom “orbiting” gravity (it’s a slingshot physics/puzzle game in space).
Here’s a picture of the scenario I’m trying to accomplish:


The black circle represents an object who’s position doesn’t change, but is rotating via a transform.RotateAround. The blue sphere is traveling with a rigidbody and velocity throughout the game area.
I already detect when the blue circle is close enough to affect the black circle’s rotation, but how can I determine which direction the black circle needs to rotate in, and by what magnitude? I think it would relate to the blue circle’s velocity, normalized vector, and position relative to the black circle- but I can’t piece the three together logically.
Keep in mind the blue circle may come from any direction, not just from below.
What I’ve tried which sorta works but not smoothly/realistically:
I’ve been attempting to calculate which Cartesian quadrant the blue circle is in based on the black circle representing the origin. Then, I determine if the blue circle is moving faster in the X or Y direction, and spin appropriately. This doesn’t always work and doesn’t look “natural”… I’m not too good at linear algebra, so I’m unsure of any other way to achieve this? Please help!
Note: I can post scripts if needed (I’m using JavaScript), but they’re a bit lengthy- I’ll leave them out for now because I think I’m going in the wrong direction and don’t want to mess anyone else up who may be in my position.
EDIT: Sorry about the pictures not showing up, they don’t seem to want to cooperate =/