Question

I have no idea how to come at this. In Python I could probably do it but I'm not that good with UnityScript. I was thinking something like this in Python:

import time 
for i in range(time):
    if(condition == True):
      #do this
    else:
       #do this
    time.sleep(1)

How would I come about doing this in UnityScript?

Was it helpful?

Solution

With a normal JavaScript implementation I would suggest using setTimeout(), but the Unity documentation suggests using Invoke() (see the docs).

function doStuff() {
    if(condition == true) {
      ...
    }
    else {
        Invoke('doStuff', 1);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top