private Quaternion[] alternativeSampleRotations; // Stors the alternative sample rotations used for undoing and redoing animations /* Coroutine that moves the dummy from its current sample to the next sample by lerping over t. Will move back to first sample after * it has reached the last sample. Stores the information in global variables lastT and lastSampleIndex for the ability to pause and * then play again from the same position. */ private IEnumerator MoveToNextSample() { if (lastSampleIndex < DMS.SFS_GetEndSliderSampleIndex()) // If last sample index isn't out of range, continue playing { if (!isPaused) { lastT = 0f; } else { isPaused = false; } while (lastT < 1) // Lerp from t being 0 to t being 1 { lastT += Time.deltaTime / DMS.SBS_GetSampleRate(); transform.position = Vector3.Lerp(samplePositions[lastSampleIndex], samplePositions[lastSampleIndex + 1], lastT); transform.rotation = Quaternion.Lerp(sampleRotations[lastSampleIndex], sampleRotations[lastSampleIndex + 1], lastT); DMS.SFS_AdjustSlider("CurrentSlider", lastSampleIndex, lastT); yield return(null); } // When it has reached the next sample, increment last sample index and start MoveToNextSample again lastSampleIndex++; yield return(StartCoroutine(MoveToNextSample())); } else // If the last sample index is out of range, reset dummy to start slider position and start MoveToNextSample again { GoToStart(); yield return(StartCoroutine(MoveToNextSample())); } }