0
Answered

For Loop only loops twice while checking for disabled objects in children when I have more

Surrealism 2 months ago updated by Lazlo Bonin (Lead Developer) 2 months ago 2

Hey, wanna ask a noob question, my for loop is supposed to loop through all children and find all the disabled objects to enable them, but every time the loop starts, it only loop through 2 times, so only 2 objects get activated, the rest remains disabled

what am I doing wrong with the forloop graph? :/ I'm basically trying to recreate this script into my bolt graph as I found some limitations on C# which bolt can easily solve later down the road

    private void OnTriggerEnter(Collider other)
    {
        onTrigger = true;
        if (other.gameObject.layer == 10 && roomIsCleared == false)
        {
            for (int a = 0; a < transform.childCount; a++)
            {
                if (transform.GetChild(a).gameObject.activeSelf == false)
                {
                    transform.GetChild(a).gameObject.SetActive(true);
                    enemySpawner.Add(transform.GetChild(a).gameObject);
                }
            }
        }
    } 
Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):

After asking around in the discord server, a kind soul has helped me solve it. Below is the solution :)

Answered

Glad you were able to figure it out! :)