Coroutine stop working after quit application (Android)

Hi! I make clicker game on Android and I wrote script on boosts for example 2x gold per click these are working for 4 hours I used “yield return new WaitForSeconds (14400.0f);” It’s working almost completly good because when buy boost and I quit game/turn off it from background then when I run game again yield is stop working.

Sorry form my mistakes in text.

Yes, the game will stop running when you stop the game.

I don’t understand the question?

1 Like

I can’t that yield stop working after quit game because then boost stop working too. Can I do something that yield will working when the game is off?

If you quit the game…the code doesn’t run…This is normal behavior…

If you need to track time when the game isn’t running you’ll need to record a timestamp of some sort. If you just want the boost to continue, you’ll need to record the time left when they quit the app. (if it’s 10000f remaining, you would use that).

You’ll probably have to change how your code works, because you’ll need to keep track of how much time has passed. Simply yielding such a large amount isn’t going to work.

So, two possible things you’re trying. You want time to pass when the game is off. In this case, you record a time stamp of when the game is closed. Then when the player logs back in, you calculate the amount of time that has passed since the game was closed (using the saved timestamp and a current timestamp).

Or, you want time to resume. In which case if you’re talking about a limited time item, then you have to record how much time has passed (or is remaining) and then when the player logs back in, you see if their boost has time remaining and start it up again using that remaining time.