Posting this since I know someone asked about stopping precisely at 360 degrees no matter the current starting rotation of the unit. Here’s how I solved it. I have a class member variable for spinAmountPerAction which is 360f.
Edit: I previously used Mathf.Epsilon to check for floating point rounding errors that could cause isActive to stay true indefinitely. But I didn’t think I used it correctly. The following edit is a better solution.
P.S. Yes, I know this is a dummy exercise but perhaps needing to do something exact would be useful in the future.
float potentialSpinAmount = 360f * Time.deltaTime;
float spinAddAmount = Mathf.Min(potentialSpinAmount, spinAmountPerAction - degreesSpunSoFar);
transform.eulerAngles += new Vector3(0, spinAddAmount, 0);
if ((degreesSpunSoFar + potentialSpinAmount) >= spinAmountPerAction)
{
isActive = false;
degreesSpunSoFar = 0;
} else {
degreesSpunSoFar += spinAddAmount;
}