using UnityEngine;

public class WaveController : MonoBehaviour
{
    private float startpos;
    public float min = -1.0f;
    public float max = 1.0f;

    static float t = 0.0f;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        startpos = transform.position.y;
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = new Vector3(Mathf.Lerp(min, max, t), startpos, 0);

        t += 0.5f * Time.deltaTime;

        if (t > 1.0f)
        {
            float temp = max;
            max = min;
            min = temp;
            t = 0.0f;
        }
    }
}
