using UnityEngine;
using System.Collections;
public class CoroutineTest : MonoBehaviour {
private Vector3 v = new Vector3();
private float speed = 0.0375f;
// Use this for initialization
void Start () {
StartCoroutine(Routine());
}
void FixedUpdate() {
transform.position += v;
}
IEnumerator Routine() {
v.z = speed;
v.x = 0;
yield return new WaitForSeconds(3f);
v.x = -speed;
v.z = 0;
yield return new WaitForSeconds(3f);
v.z = -speed;
v.x = 0;
yield return new WaitForSeconds(3f);
v.z = 0;
v.x = speed;
yield return new WaitForSeconds(3f);
StartCoroutine(Routine());
}
}