Hi all, I'm trying to implement a system where my gameObjects move in a "path" or loop using coroutines and rigidbody.addvelocity. It works kind of like below: The only problem is that my code is kind of... a mess. It uses public Vector2 & floats for travel time with a repeating pattern of coroutines and an int to determine whether it loops back to the first step on each one. I was wondering if anybody had any suggestions on how to clean it up a little and make it more workable. I tried using arrays for vectors and waitTime but I couldn't figure out how to start a coroutine for undeclared (in code) variables. If anybody could offer any suggestions on improving this code, I'd greatly appreciate it! Here is the code: Code (CSharp): public Vector2 posOne = new Vector2 (0, 0); public float waitOne = 1.0f; public Vector2 posTwo = new Vector2 (0, 0); public float waitTwo = 1.0f; public Vector2 posThree = new Vector2 (0, 0); public float waitThree = 1.0f; public Vector2 posFour = new Vector2 (0, 0); public float waitFour = 1.0f; public Vector2 posFive = new Vector2 (0, 0); public float waitFive = 1.0f; public Vector2 posSix = new Vector2 (0, 0); public float waitSix = 1.0f; public Vector2 posSeven = new Vector2 (0, 0); public float waitSeven = 1.0f; public Vector2 posEight = new Vector2 (0, 0); public float waitEight = 1.0f; public Vector2 posNine = new Vector2 (0, 0); public float waitNine = 1.0f; public Vector2 posTen = new Vector2 (0, 0); public float waitTen = 1.0f; public Vector2 posEleven = new Vector2 (0, 0); public float waitEleven = 1.0f; public Vector2 posTwelve = new Vector2 (0, 0); public float waitTwelve = 1.0f; public int loopOnStep = 12; public float accelerationForce = 10; void Start () { StartCoroutine ("firstPos"); } IEnumerator firstPos () { rigidbody.velocity = posOne; yield return new WaitForSeconds (waitOne); if (loopOnStep == 1) { StartCoroutine ("firstPos"); } else { StartCoroutine ("secondPos"); } } IEnumerator secondPos () { rigidbody.velocity = posTwo; yield return new WaitForSeconds (waitTwo); if (loopOnStep == 2) { StartCoroutine ("firstPos"); } else { StartCoroutine ("thirdPos"); } } IEnumerator thirdPos () { rigidbody.velocity = posThree; yield return new WaitForSeconds (waitThree); if (loopOnStep == 3) { StartCoroutine ("firstPos"); } else { StartCoroutine ("fourthPos"); } } IEnumerator fourthPos () { rigidbody.velocity = posFour; yield return new WaitForSeconds (waitFour); if (loopOnStep == 4) { StartCoroutine ("firstPos"); } else { StartCoroutine ("fifthPos"); } } IEnumerator fifthPos () { rigidbody.velocity = posFive; yield return new WaitForSeconds (waitFive); if (loopOnStep == 5) { StartCoroutine ("firstPos"); } else { StartCoroutine ("sixthPos"); } } IEnumerator sixthPos () { rigidbody.velocity = posSix; yield return new WaitForSeconds (waitSix); if (loopOnStep == 6) { StartCoroutine ("firstPos"); } else { StartCoroutine ("seventhPos"); } } IEnumerator seventhPos () { rigidbody.velocity = posSeven; yield return new WaitForSeconds (waitSeven); if (loopOnStep == 7) { StartCoroutine ("firstPos"); } else { StartCoroutine ("eighthPos"); } } IEnumerator eighthPos () { rigidbody.velocity = posEight; yield return new WaitForSeconds (waitEight); if (loopOnStep == 8) { StartCoroutine ("firstPos"); } else { StartCoroutine ("ninthPos"); } } IEnumerator ninthPos () { rigidbody.velocity = posNine; yield return new WaitForSeconds (waitNine); if (loopOnStep == 9) { StartCoroutine ("firstPos"); } else { StartCoroutine ("tenthPos"); } } IEnumerator tenthPos () { rigidbody.velocity = posTen; yield return new WaitForSeconds (waitTen); if (loopOnStep == 10) { StartCoroutine ("firstPos"); } else { StartCoroutine ("eleventhPos"); } } IEnumerator eleventhPos () { rigidbody.velocity = posEleven; yield return new WaitForSeconds (waitEleven); if (loopOnStep == 11) { StartCoroutine ("firstPos"); } else { StartCoroutine ("twelthPos"); } } IEnumerator twelthPos () { rigidbody.velocity = posTwelve; yield return new WaitForSeconds (waitTwelve); if (loopOnStep == 12) { StartCoroutine ("firstPos"); } else { StartCoroutine ("firstPos"); } }