// Update is called once per frame void Update() { if (waypointIndex <= waypoints.Count - 1) { transform.position = Vector2.MoveTowards(transform.position, waypoints[waypointIndex].position, waveConfig.getMoveSpeed() * Time.deltaTime); if (transform.position == waypoints[waypointIndex].position) { waypointIndex++; } } else { Destroy(gameObject); } }