private IEnumerator FollowCurveFixedSpeed(List <Transform> curve) { // create list of waypoints based on bezier curve, var waypointList = new List <Vector2>(); for (float t = 0; t <= 1; t += (1f / waveConfig.GetNumWaypoints())) { var newPos = Mathf.Pow(1 - t, 3) * curve[0].position + 3 * Mathf.Pow(1 - t, 2) * t * curve[1].position + 3 * (1 - t) * Mathf.Pow(t, 2) * curve[2].position + Mathf.Pow(t, 3) * curve[3].position; newPos = ApplyReverse(newPos); newPos = ApplyOffset(newPos); waypointList.Add(newPos); } // moves from waypoint to waypoint at fixed speed, yielding at each frame int currentWaypointIndex = 0; while (currentWaypointIndex <= waypointList.Count - 1) { var targetPos = waypointList[currentWaypointIndex]; var deltaMove = waveConfig.GetEnemySpeed() * Time.deltaTime; var newPos = Vector2.MoveTowards(transform.position, targetPos, deltaMove); if (newPos != targetPos) { yield return(transform.position = newPos); } else { currentWaypointIndex++; } } }