I have a function that calls itself a few times over and over to get a certain result. Everything in it works, but sometimes it goes into too many functions (of itself) and causes a frame rate spike. So, I want to pause all the current functions for a frame, and then resume.
Now I thought that if I use sleep() at the beginning of the function it would work but its not working. I have a counter which checks how many times the function has been called, my.cur_depth, and I use this to pause it: if(my.cur_depth % 20==0){sleep(1);}
But its not working the same as when it is without the above. Anyone have any ideas of what I could do?