Simple Set Array not working

Hello, this is my code to grab all the tagged creature spawners in my level and set an array with all of them.

var Spawners : []creature_spawner_device = array{}
InitSpawners(): void =
        TempSpawners := GetCreativeObjectsWithTag(MonsterSpawner{})
        var Iterator: int = 0
        for(Index -> TempSpawner : TempSpawners):
            #cast to creature spawner
            if(ValidSpawner:= creature_spawner_device[TempSpawner]):
                Print("Cast")
                #Add to spawners array
                if(set Spawners[Index] = ValidSpawner):
                    Print("Num spawners added: {Index}")
                else {Print("Set Array Failed")}

This ends up printing Cast, then Set Array Failed for each spawner in my level every time, and I am confused what I am doing wrong as I have this exact same code on another project but it works fine. It is finding the objects, casting them, but setting the array is not working. Any help is greatly appreciated!

The way I add stuff to an array is usually the following way

set MyArray += array{ThingIwantAddedHere}

try replacing it with that and let me know if it works

This worked, thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.