How do I Detect if an object has made a full rotation and gradually change its color


Has topic suggests I need to detect full rotation of an object.
While doing this i want that the color of the object will change from white (starts rotation at 0 degrees) to to green (at full rotation, return back to starting position)

For change color i am usings Lerp:

 LetterText.color = Color.Lerp(Color.white,, Mathf.Abs(currentLetterGameObject.transform.rotation.z));

Which only works half way since it’s goes from 0 to 1 (180 degree) and 1 to 0 (other 180 degree)

Object is rotated inside Update() function.

You want transform.eulerAngles, not transform.rotation##

Transform.rotation is the Quaternion representation of the object’s rotation, and Z is a number between 0 and 1 and does not correspond to the actual 360 rotation (by itself). What you want to use is transform.eulerAngles.

The final code is as follows (notice the division):

LetterText.color = Color.Lerp(Color.white,, Mathf.Abs(currentLetterGameObject.transform.eulerAngles.z / 360));

For what it’s worth, you were close :slight_smile: