Is there an easy way to make a function loop? For example, one line of code at the end of the function that basically says “repeat”?
I’ve used this kind of code:
for (t=0;t<50;t++) {
}
But is there a better way, and one that loops infinitely?
Is there an easy way to make a function loop? For example, one line of code at the end of the function that basically says “repeat”?
I’ve used this kind of code:
for (t=0;t<50;t++) {
}
But is there a better way, and one that loops infinitely?
What you don’t want to do is loops like this:
function Start ()
{
Loop();
}
function Loop ()
{
// do stuff
yield;
Loop();
}
As they leak memory very quickly and lead to crashes.
The official way to create a loop is like this:
function Start ()
{
Loop();
}
function Loop ()
{
while(true)
{
// do stuff
yield;
}
}
“while(true)”, eh? Short, easy, it works…
Perfect, thanks!