Hello, I am creating a minigame that involves rotating colored circles so that the colors match relative to the central circle which is not rotatable. I was thinking of checking with colliders that the two points at the beginning of one color and the end match with some tolerance to the other circle which also has such collider points set, but I don’t know if this is a good solution.
Graphics in attach is only placeholder and that reason is little unscale.
Current rotate script:
public class RotateCircleMinigame: MonoBehaviour
{
private Vector3 screenPos;
private float angleOffset;
void Update()
{
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (Input.GetMouseButtonDown(0))
{
screenPos = Camera.main.WorldToScreenPoint(transform.position);
Vector3 vector3 = Input.mousePosition - screenPos;
angleOffset = (Mathf.Atan2(transform.right.y, transform.right.x) - Mathf.Atan2(vector3.y, vector3.x)) * Mathf.Rad2Deg;
}
if (Input.GetMouseButton(0))
{
Vector3 vector3 = Input.mousePosition - screenPos;
float angle = Mathf.Atan2(vector3.y, vector3.x) * Mathf.Rad2Deg;
transform.eulerAngles = new Vector3(0, 0, angle + angleOffset);
}
}
}