This is from the Walker Boys tutorial, game 1.
I have assigned the script to two objects and I want a specified one to as the counter ticks down and then to reappear and change its position when the countdown goes to zero. However, the function I pasted below seems to be working peculiarly. When I apply it in the start() function, it seems to work fine. The object blinks and then reappears in another place, but since it is the start function, it only does that when I start the game. Now, when I put my Countdown1() function (shown below) in the Update() function, the object seems to disregard the counter and starts to appear randomly, switching its position multiple times and refusing to stay still and blink until the counter ends.
Since I am a beginner, I have very much exhausted the knowledge available to me and have been at this for quite a while. Some tips would be great.
function Countdown1()
{
while (countdown2 > 0)
{
yield WaitForSeconds(0.3);
sphereDisappear.renderer.enabled = false;
yield WaitForSeconds(0.3);
sphereDisappear.renderer.enabled = true;
countdown2--;
}
if (countdown2 == 0)
{
countdown2 = 3;
var newPosition = Vector3(Random.Range(-4, 4), Random.Range(-4, 4), 0);
sphereDisappear.transform.p osition = newPosition;
}