- Home /
Question by
TheHoongs · May 13, 2014 at 07:22 AM ·
loopwaitforsecondssetactive
Looping Blinker Doesn't work
I am now learning JavaScript and I have an issue!
I want the script below to loop. Loop like a gameobject appears and disappears again and again!
var openTime : float = 1;
var closeTime : float;
var blinkerObj : GameObject;
function Start() {
flickerLight();
}
function flickerLight() {
for (var x = true; x > false;) {
yield WaitForSeconds(openTime);
blinkerObj.SetActive(true);
yield WaitForSeconds(closeTime);
blinkerObj.SetActive(false);
}
}
Comment
Best Answer
Answer by Maerig · May 13, 2014 at 08:17 AM
A while
loop seems more appropriate here :
function flickerLight() {
while(true) {
yield WaitForSeconds(openTime);
blinkerObj.SetActive(true);
yield WaitForSeconds(closeTime);
blinkerObj.SetActive(false);
}
}
Good luck !
Answer by screenname_taken · May 13, 2014 at 08:56 AM
I just did mine with a looping animation :P Toggling visibility. Doundabout way i know. But for some reason i couldn't get my script to do what i wanted.