using UnityEngine;

namespace MPStudio
{
    public class UpDownMove : MonoBehaviour
    {
        public float speed = 0.25f; // 移动速度
        public float distance = 0.05f; // 移动距离

        private Vector3 startPosition;

        void Start()
        {
            // 记录初始位置
            startPosition = transform.position;
        }

        void Update()
        {
            // 使用PingPong函数计算Y轴位置
            float newY = Mathf.PingPong(Time.time * speed, distance);

            // 更新物体位置
            transform.position = startPosition + Vector3.up * newY;
        }
    }
}