How to run some code in Unity3D after every x seconds? -
i need execute code every x seconds till condition met in unity3d c#. code should run irrespective of other code long condition true , stop otherwise. condition turns false, should stop executing , run again if condition becomes true (counting no. of seconds 0 again if possible). how that?
something should work.
void start(){ startcoroutine("dostuff", 2.0f); } ienumerator dostuff(float waittime) { while(true){ //...do stuff here if(somestopflag==true)yield break; else yield return new waitforseconds(waittime); } }
Comments
Post a Comment