using UnityEngine;

public class Saw : MonoBehaviour
{
    [SerializeField] private Transform[] points;
    [SerializeField] private float moveSpeed = 2f;
    private int pointIndex;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        pointIndex = 0;
    }

    // Update is called once per frame
    void Update() {

        if (Vector2.Distance(transform.position, points[pointIndex].position) < .1f) {
            pointIndex++;
        }

        if (pointIndex == points.Length) {
            pointIndex = 0;
        }

        transform.position = Vector2.MoveTowards(transform.position, points[pointIndex].position, moveSpeed * Time.deltaTime);
    }
}
