Enemy attack

I followed a tutorial to make sure that the enemy arttacchi the player. With this script the enemy attacks the player from the current position and then return to the starting point. I did not understand how it is possible using the Lerp

   IEnumerator Attack()
    {
        Vector3 originalPosition = this.transform.position;
        Vector3 attackPosition = target.position;
        float attackSpeed = 3f;
        float percent = 0;

        while(percent <=1)
        {
            percent += Time.deltaTime * attackSpeed;
            float interpolation = (-Mathf.Pow(percent,2)+percent)*4;
            transform.position = Vector3.Lerp(originalPosition,attackPosition,interpolation);
         
            yield return null;
        }
    }

What exactly is your question? :slight_smile: