I move some objects using coroutine, and I will do something else when the coroutines end.
How can I detect the coroutine ends? This is not easy for me.
My code is like this…
bool coroutineEnd = false;
void Update() {
if (coroutineEnd) doFuntionB();
if (!coroutineEnd) doFunctionA();
}
void doFunctionA() {
for(int i=0; i<4; i++) {
StartCoroutine(moveObj());
}
coroutineEnd = true;
}
IEnumerator moveObj() {
while(true) {
if (condition) break;
transform.Translate(Vector3.right * Time.deltaTime);
yield return 0;
}
}
void doFunctionB() {
....
coroutineEnd = false;
}
Problem is doFunctionB(0 starts before doFunctionA() ends.
Is this right way to handle this kind of job?
Thanks in advance for any advice.