- Home /
Re-enable invoke repeating after using CancelInvoke();
Hey guys,
Quick question. I am using an InvokeRepeating to decrease my score every 5 seconds. When my score reaches 0, I use CancelInvoke to prevent it from going lower than 0. But if I then change my score, the InvokeRepeating won't start again because it has been canceled when my score reached 0. How do I re-enable my InvokeRepeating after using CancelInvoke?
Thanks,
Using a check as suggested below works in your specific use case. Generally, if InvokeRepeating needs to be cancelled and restarted repeatedly, consider using Coroutines ins$$anonymous$$d.
Answer by Sergio7888 · Nov 19, 2016 at 11:22 PM
Don't use CancelInvoke, simple put in your function a check if the value is equal or less than zero before reduce the score.
forgot to do that ;P
Thanks a lot for helping :D
Don't ask for marking an answer as correct until the OP confirms that it solves the issue.