# IEnumerator doing something wierd

here’s the script

``````using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Everything : MonoBehaviour {

public Transform Boomerang;
public Transform Forward;
public Transform Right;
public Transform Left;
public Transform Backward;
public bool rightisgoing = false;
public bool leftisgoing = false;
public float a;
public float b;

void Update () {
Boomerang.transform.Rotate (0, 5, 0);
if (Input.GetKey (KeyCode.RightArrow) && rightisgoing == false) {
StartCoroutine (BRight (1));
}
if (Input.GetKey (KeyCode.LeftArrow) && leftisgoing == false) {
StartCoroutine (BLeft (1));
}
}

IEnumerator BRight(float a) {
rightisgoing = true;
aaa:
if (a <= 225) {
a++;
if (a <= 100) {
Boomerang.position = Vector3.MoveTowards (Boomerang.position, Forward.position, 0.1f);
}
if (a <= 150 && a >= 101) {
Boomerang.position = Vector3.MoveTowards (Boomerang.position, Right.position, 0.1f);
}
if (a <= 225 && a >= 151) {
Boomerang.position = Vector3.MoveTowards (Boomerang.position, Backward.position, 0.1f);
}
goto aaa;
} else {
a = 0;
rightisgoing = false;
}

yield return new WaitForSeconds (0.0f);
}

IEnumerator BLeft (float b) {
leftisgoing = true;
bbb:
if (b <= 100) {
Boomerang.position = Vector3.MoveTowards (Boomerang.position, Forward.position, 0.1f);
}
if (b <= 150 && b >= 101) {
Boomerang.position = Vector3.MoveTowards (Boomerang.position, Left.position, 0.1f);
}
if (b <= 225 && b >= 151) {
Boomerang.position = Vector3.MoveTowards (Boomerang.position, Backward.position, 0.1f);
}
if (b <= 225) {
b++;
goto bbb;
} else {
b = 0;
leftisgoing = false;
}
yield return new WaitForSeconds (0.0f);
}
}
``````

it just moves the boomerang forward, up, and to the right
before I moved the script into a coroutine, it worked fine

it moves the boomerang about (0.4, 0.4, 0.8)
Boomerang coords were (0, 0, 0) (Empty parent of 2 child stretched spheres)
Forwards coords (0, 5, 10) (Empty)
Backwards coords (0, 0, 0) (Empty)
Right coords (5, 3, 6) (Empty)
Left coords (-5, 3 6) (Empty)