Let’s break it down into the parts of the problem.
- Detect that the user is “grabbing” the wheel. Easy enough with a raycast
- Detect that the user is rotating the mouse around the center.
- Apply the appropriate rotation to the model
It seems like #2 is the main thing you need help with, correct?
So while the user is turning the wheel, there are two points that matter: The center of the wheel, and the position of the mouse. It’s easiest on the math if both of these are in screen space, though that will only really look right as long as the player is in front of the wheel, so you may want to enforce that. You can use Camera.main.WorldToScreenPoint(wheelCenter.transform.position) to put that into screen space, and Input.mousePosition will give you the mouse.
So now we have those two positions, it’s time for MATH! We’re actually going to reduce the two positions into one - subtract the wheel center from the mouse position. This is now the position of the mouse, relative to the center. We need to turn this into an angle, and Unity’s math library provides just the thing: Mathf.Atan2(y, x). It does precisely when we need it for here. Note that 1) its parameters are (y, x), in that order; and 2) it output the result in radians, which you probably want to convert to degrees by multiplying by Mathf.Rad2Deg.
So now we have reduced all our numbers to one magic number, the angle. From here it should be a relatively simple matter to rotate the wheel by the same angle. You’ll want to store the result from last frame, and subtract the two angles, so that only the difference is what you rotate the wheel by.
One more issue you’ll have to contend with: at some point in the circle, you’re gonna go from 359.9 to 0. This is a special case to program for, but it’s not too difficult. Since every frame, the player will only turn it by a small number of degrees - less than 180 - we can use that threshold to modify this frame’s angle so that it’s always smoothly proceeding from last frame’s:
while (lastFrameAngle > thisFrameAngle + 180f) {
thisFrameAngle = thisFrameAngle + 360f;
}
You might not notice the issue visually, but assuming you are going to be checking for X turns, this is how you’ll do it.
And that’s pretty much that. If there are any parts of this that need clarification, ask.