gameObject.active = true ; every second for 5 seconds

hi again …
why this script … dont give an error but is not working
only works one time

i need to gameobject.active = true every second for 5 seconds
how can I do.

I have this code

function emite_nemy ()
{  
for (var i : int = 0; counter < 5; counter ++ )
{
anotherobject.gameObject.active = true ;
yield WaitForSeconds (1) ;
anotherobject.gameObject.active = false ;
} 
}

any help please…

Just a guess (not sure what you’re trying to do), but it sounds like you might want another yield after your active=false line, or you’ll flip back to true immediately. On a side note, you might want to get used to using SetActive(), since I believe “active” is deprecated (going away eventually).

Yeah, what are you trying to achieve here? What is the behaviour you want and what are you getting?

I can see what that code does, but I don’t know how that’s different from what you want it to do, so it’s hard to help.

Your for loop is wrong too - for (var i : int = 0; counter < 5; counter ++ ).

Doesn’t seem like logical code though in the first place. Best to let people know what you’re trying to achieve.