using UnityEngine;

namespace MPStudio
{
    public class SmoothMovement : MonoBehaviour
    {
        public Transform target; // 目标位置
        public float duration = 1f; // 过渡时间
        private float timer = 0f;
        private Vector3 startPos;

        void Start()
        {
            startPos = transform.position;
        }

        void Update()
        {
            if (timer < duration)
            {
                timer += Time.deltaTime;
                
                /*
                 *
                 *
SmoothStep → 控制时间进度曲线（让运动更自然）

Lerp → 计算空间位置（根据曲线值确定具体坐标）

二者组合是 游戏开发中平滑移动的标准做法，不是冗余操作。
                 */
                float t = Mathf.SmoothStep(0f, 1f, timer / duration);
              //float t = timer / duration;
                transform.position = Vector3.Lerp(startPos, target.position, t);
            }
        }
    }
}