Circle color rotate minigame problem

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);
        }
    }
}

8438792--1118180--ColorCircleMinigame1.png
8438792--1118183--ColorCircleMinigame2.png

Just ignore the colliders and graphics.

Instead make a data structure for each color ring that represents the angle of the desired color(s), the angle span of “being aligned,” and then let the user change the presented angle, which would drive the graphics.

All your logic would do is tally up the angles, check them against being close enough to be lined up.

Mathf.DeltaAngle() may be a useful function for you.

2 Likes