[SOLVED] foreach-Loop not workin with Unity 2017

The statements within foreach loop are never executed - but i dont’t know, why. It seems to be, that never any child is found. I don’t get any errors.

void Update()
{
float propability = Time.deltaTime * shotsPerSeconds;
if (Random.value < propability)
{
Fire();
}

    if (AllMembersDead())
    {
        //Debug.Log("Empty Formation");
    }
}

bool AllMembersDead()
{
    foreach (Transform childPositionGameObject in transform)
    {
        if (childPositionGameObject.childCount > 0)
        {
            return false;
        }
    }
    return true;
}

Uhhh, big mistake :wink:

I put the code in the wrong script! Never try to learn something new, if day was long and you are tired… :flushed:

Privacy & Terms