I have an application I’m developing for iOS. When an object is touched, it disappears, adds points to a score, and then respawns in a new location after 5 seconds. I’m having trouble with the object respawning, but the essential problem is in the abbreviated script I wrote below. Why doesn’t this code re-activate the game object and what’s the best way to toggle between active and inactive for iOS?
function Start () {
gameObject.active = false;
yield WaitForSeconds(5.0); // wait for 5 seconds
gameObject.active = true;
yield WaitForSeconds(5.0); // wait for 5 seconds
gameObject.active = false;
yield WaitForSeconds(5.0); // wait for 5 seconds
gameObject.active = true;
}