Issue with Lerping Scale - Not another "what is T" question

Hi guys.

        protected override IEnumerator IPlayForward()
        {
            _currentDuration = 0;

            while (_currentDuration < duration || duration < 0)
            {
                _t.localScale = Vector3.Lerp(_t.localScale, desiredScale, _currentDuration / duration);
                yield return StartCoroutine(WaitAndIncrement_IEnumerator(Time.deltaTime));

            }
        }

currentDuration is a value that is being incremented by the Coroutine “WaitAndIncrement_IEnumerator.”

In a simple Debug.Log() it shows that the value is lerping correctly, but the scale is going way too fast. It finishes roughly halfway to 3/4 of way through.

Local Scale for my object is 1,1,1 and the desired scale is 2,2,2.

Any help is greatly appreciated!

*With a 2 second duration, the scale jumps from 1 to 1.9 within the first second, and takes another second to finish the scale

Your problem is in your Lerp() call. When using Lerp() the way you are using it here, you want the first parameter of the Lerp() to be the starting scale. You don’t want to use the current scale. The code would be something like:

protected override IEnumerator IPlayForward()
        {
            _currentDuration = 0;
            Vector3 startScale = _t.localScale;
 
            while (_currentDuration < duration || duration < 0)
            {
                _t.localScale = Vector3.Lerp(startScale, desiredScale, _currentDuration / duration);
                yield return StartCoroutine(WaitAndIncrement_IEnumerator(Time.deltaTime));
 
            }
        }