I have a basic StartCoroutine script and it works but in the StopCoroutine script it just doesn’t work at all
if (walkno == 1) {
StartCoroutine (walk ());
}
if (walkno == 0) {
StopCoroutine (walk ());
}
walkno is a public float and in the inspector it says it is at zero yet the coroutine doesn’t stop
eses
2
@JDVDeisgn : Hi there, I think you have to stop it with string method name:
StopCoroutine("Walk");
Either as eses said or there are other ways:
- Save IEnumerator that StartCoroutine returned and StopCoroutine on it.
- yield break; from inside coroutine.
eses
4
…Sorry, forgot to mention, to be able to stop coroutine like I mentioned, I think you also have start it like this too:
// not stopped
StartCoroutine(Test());
StopCoroutine("Test");
// Works
StartCoroutine("Test");
StopCoroutine("Test");
1 Like