I have a cube. I want it to move left and right on the screen.
How can i make the cube on the screen move the opposite direction after a set time?
It moves along the x axis.
void Update () {
StartCoroutine(Example());
}
IEnumerator Example() {
float f = speed * Time.deltaTime;
transform.Translate(f,0,0);
yield return new WaitForSeconds(5);
// after 5 secs send the object the opposite direction
}