Hello Guys,

I hope there is a vector math formula for this.

Rules are simple:

- GameObject can be rotated to the

right or left from any point. - If player change rotation direction

we need to start measuring a new 360

rotation. - Color change from white to green

when measuring the 360 rotation.

This is my current code:

```
private void Update()
{
Vector3 temp = Input.acceleration.normalized;
temp.z = 0;
currentLetterGameObject.transform.up = temp.normalized;
//direction right
if (MyGameObject.transform.eulerAngles.z > previousAngle)
{
if (rotationRight)
{
rotationCount = 0;
startRotationAngle = previousAngle;
rotationRight = false;
}
rotationCount = (Mathf.Abs(MyGameObject.transform.eulerAngles.z) - Mathf.Abs(startRotationAngle)) / 360;
MyGameObject.GetComponent<LetterBase>().LetterText.color = Color.Lerp(gameController.LetterDefaultColor, Color.green, rotationCount);
}
//direction left
if (MyGameObject.transform.eulerAngles.z < previousAngle)
{
if (!rotationRight)
{
rotationCount = 0;
startRotationAngle = previousAngle;
rotationRight = true;
}
rotationCount = (Mathf.Abs(MyGameObject.transform.eulerAngles.z - 360) - Mathf.Abs(startRotationAngle - 360)) / 360;
MyGameObject.GetComponent<LetterBase>().LetterText.color = Color.Lerp(gameController.LetterDefaultColor, Color.green, rotationCount);
}
//full circle
if (rotationCount > 0.925f)
{
MyGameObject.LetterText.color = Color.green;
rotationCount = 0;
Debug.log("END OF GAME");
//Quit
}
}
```

**Issues:**

- It’s not solid code, i look for

rotationCount>0.925f to try to

detect full circle, and it can be

skipped if player moves rotation too

fast. - If reaching

MyGameObject.transform.eulerAngles.z

to ZERO angle it reset the color to white and reset

starting point (it jumps between two

“if’s” and reset parameters).

This is a challenge if someone accepts it, i can’t seem to solve it correctly… :\