using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WaterWavesController : MonoBehaviour
{
    [SerializeField] private float scrollSpeed = 0.5F;
    [SerializeField] private float timeToInvert = 0.5F;
    private float timeToInvert_;
    private float dir = 1;
    private Renderer rend;

    private void Start()
	{
        rend = GetComponent<Renderer>();
    }
    private void Update()
	{
		timeToInvert_ -= Time.deltaTime;

		if (timeToInvert_ <= 0)
		{
			dir *= -1;
			timeToInvert_ = timeToInvert;
		}

        float offset = Time.deltaTime * scrollSpeed * dir;
        rend.material.mainTextureOffset = new Vector2(offset, 0);
    }
}
