execute something for 5 seconds unity code example
Example: execute something for 5 seconds unity
StartCoroutine(GoLeft()); IEnumerator GoLeft() { // This will wait 1 second like Invoke could do, remove this if you don't need it yield return new WaitForSeconds(1); float timePassed = 0; while (timePassed < 3) { // Code to go left here timePassed += Time.deltaTime; yield return null; } }