How to disable a Coroutine
I have this in Update():
if (GameObject.Find("player4") != null) {
StartCoroutine(startgame());
}
How can I then disable the coroutine so it doesn't run again, as player4 is now in the game?
Thanks
Comment
Write this: StopCoroutine(startgame());
When you want to stop the coroutine
if (GameObject.Find("player4") != null) {
StartCoroutine(startgame());
StopCoroutine(startgame());
}
So that would stop the coroutine ever running again, even though it's in the update?
No it won't it just immediatly stops the coroutine. You could maybe try a bool and see if the coroutine has ever started. I donno