I am debugging my Lerping to see how it works. It is rotating a card and it looks good. However the lerping contains way beyind the card is visually done rotating. I understand it has to do with the mathematics. Is thera a way i can fix it? Is it unavoidable with Lerp/Slerp? Basically what i want is the function to be done when the card has rotated enough so that steps are no longer visible.
public IEnumerator LerpRotationY (float durationSeconds, FlipsSide flipSide)
{
int targetAngle = FlipSideEnumToDegrees (flipSide);
//float flipSpeed = 3F;
var flipRotation = Quaternion.Euler (0, targetAngle, 0);
float t = Time.deltaTime;
var cardRotation = cardSides.rotation;
var timePassed = Time.time;
print ("SLERPING! ");
while (t < durationSeconds) {
cardSides.rotation = Quaternion.Slerp (cardSides.rotation, flipRotation, t);
yield return null;
t += Time.deltaTime;
}
print ("SLERPING FINISHED: " + (Time.time - timePassed).ToString ());}