Make a platform disappear after the next one appear

Hi everybody !

I pretty nex to Unity and c# and I’m making a 3D platform game in which I would implement the same mechanic than in HeatMan stage from MegaMan 2. Make platforms disappear as the next appear.

I tried to make my plateforms appear while every other disappear, but it doesn’t work correctly.

Here’s what I’ve tried so far :

void Update ()
{
    StartCoroutine(MegaManTrap());
}

IEnumerator MegaManTrap()
{
    for (int i = 0 ; i < pf.Length ; i++)
    {
        if (pf*.activeInHierarchy == false)*

{
pf*.SetActive(true);*
}
yield return new WaitForSeconds(Pop);
for (int v = 0 ; v < pf.Length ; v++)
{
if (v != i)
{
if (pf*.activeInHierarchy == true)*
{
pf*.SetActive(false);*
}
}
}
yield return new WaitForSeconds(Depop);
}
}
I don’t find the right way to do this, is it possible to have some help plz =) ?

I don’t know yet if the coroutine is written correctly in terms of the logic but you are starting a coroutine every frame so that is surely one problem that must be fixed. See what happens if you start the coroutine once in Start() function instead of Update()

Oh, it worked pretty well, every platforms appear and disappear as expected but just once, how can I make the coroutine loop while I play in the start function ?