void Update() { if (Time.time > startTime + delay) { // get children positions as ratios var maxDist = math1.Math.GetDistance(); List <Transform> trList = new List <Transform>(); List <float> ratioList = new List <float>(); foreach (Transform t in transform) { if (t != transform) { // get current position ratio float curDist; math1.CalcPositionByClosestPoint(t.localPosition, out curDist); // compare using local position var curRatio = curDist / maxDist; trList.Add(t); ratioList.Add(curRatio); } } // useful distances maxDist = math1.Math.GetDistance(); var spacingRatio = spacing / maxDist; float deltaRatio = Time.deltaTime * speed / maxDist; // update positions in curve float ratio = 1f + spacingRatio - 0.01f; for (int j = 0; j < trList.Count && j < ratioList.Count; j++) { ratio = Mathf.Min(ratioList[j] + deltaRatio, ratio - spacingRatio); var pos = math1.CalcByDistanceRatio(BGCurveBaseMath.Field.Position, ratio); trList[j].localPosition = pos; // set via local position // if ratio is close to 1.0, remove from list of children and zoom to player if (handleIdle && ratio >= .95f) { trList[j].parent = null; gameCtrl.EnemyIdle(trList[j].gameObject); } } } }