- Home /
Transition between rotations
Hey, I'm trying to transition from a continuous rotation into a gradually slower one until a stop at a specified angle. Way I've been trying to do this is:
transform.Rotate(Vector3.forward * 10f);
This is the continuous rotation. When I need it to stop I'm trying to transition into this coroutine:
float angle = i_NumberOfSpins * 360 + i_AngleToStopAt;
m_IsSpinning = true;
float timer = time / 2;
float startAngle = transform.eulerAngles.z;
while (timer < time)
{
float endAngle = m_AnimationCurve.Evaluate(timer / time) * angle;
transform.eulerAngles = new Vector3(0.0f, 0.0f, (endAngle + startAngle));
timer += Time.deltaTime;
yield return 0;
}
This is using an animation curve to slowly stop the spinning. Problem is the wheel is making a big jump in angles between the transitions. Any idea why or how to fix this?
Comment