- Home /
CancelInvoke doesnt cancel InvokeRepeating?
Hello, i have an issue using InvokeRepeating. My scenario requires me to setup InvokeRepeating and to change its repeating rate at specific events. But when i change the rate it doenst cancel the previous invokerepeating.
Basically in my Start() method i have InvokeRepeating("Method", 0, X);
Later triggered by some events, a method for this game object is called that should modify the repeat rate. So i do in my method of the game object:
CancelInvoke("Method"); InvokeRepeating("Method", 0, Y);
But since the first InvokeRepeating (the one from the Start()) doesnt get canceled now i have 2 invokes every X seconds. What could be the reason for the first event to not get canceled?
Hey :)
$$anonymous$$ight be better to put your "answer" as a comment on my question. Also this was back in 2013, a lot has changed since, and probably the problem i had is no longer relevant.
If i remember correctly there was a bug in InvokeRepeating that made it impossible in some cases to start at 0 time (second param). Pretty sure that was resolved in following Unity updates though :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613103137im_/https://answers.unity.com/themes/thub/images/avi.jpg)