Esempio n. 1
0
    private int personalDummyIndex;              // The index that represents the respective dummy in DMS for this particular ghost

    /* Coroutine that takes in a ghost sample index and begins moving to the next sample index by lerping over t. Will increment the ghost sample index and call itself
    * once t is greater than 1. If the ghost sample index becomes greater than the end slider sample index, will start the ghost from the start slider sample index. */
    private IEnumerator MoveGhostToNextSample(int ghostSampleIndex)
    {
        if (ghostSampleIndex < sliderFieldScript.GetEndSliderSampleIndex())
        {
            float t = 0f;
            while (t < 1)
            {
                t += Time.deltaTime / speedBandScript.GetSampleRate();
                transform.position = Vector3.Lerp(DMS.DS_GetSamplePosition(personalDummyIndex, ghostSampleIndex), DMS.DS_GetSamplePosition(personalDummyIndex, ghostSampleIndex + 1), t);
                transform.rotation = Quaternion.Lerp(DMS.DS_GetSampleRotation(personalDummyIndex, ghostSampleIndex), DMS.DS_GetSampleRotation(personalDummyIndex, ghostSampleIndex + 1), t);
                DMS.SFS_AdjustSlider("GhostSlider", ghostSampleIndex, t);
                yield return(null);
            }
            yield return(MoveGhostToNextSample(ghostSampleIndex + 1));
        }
        else
        {
            transform.position = DMS.DS_GetSamplePosition(personalDummyIndex, sliderFieldScript.GetStartSliderSampleIndex());
            transform.rotation = DMS.DS_GetSampleRotation(personalDummyIndex, sliderFieldScript.GetStartSliderSampleIndex());
            yield return(MoveGhostToNextSample(sliderFieldScript.GetStartSliderSampleIndex()));
        }
    }