Hi There!
I’ve been trying to make a simple dash function:
IEnumerator Dash() {
for (float i = 0; i < 150; i += 20) {
speed = 110 + i;
yield return new WaitForFixedUpdate();
}
speed = 60f;
for (int i = 0; i < 48; i++) {
if (!dashCanStartAgain) {
yield return new WaitForFixedUpdate();
} else {
yield break;
}
}
dashCanStartAgain = false;
dashKeyTrigger = false;
}
Basically, dashCanStartAgain is changed in another function, and I want that we exit the for-loop through the “yield break”. The problem seems to be that the for loop does not seem to notice any changes in the bool, and always goes into the first statement.
Is that the nature of forloops in couroutines or am I missing something? I am sure that dashCanStartAgain IS being changed.
Cheers!
Luke