How can I check how many times a variable is true?

So, i’m working in this “mini-game” i’m doing, there are some red plates on the floor that when you colide with, it turns blue, and to change the texture i created a variable called “IsOn?” that checks when the player colides, if it does colide it returns true to the var, so my question is, there’s a way to check how many times this “IsOn?” var is returning true? cause there’s 9 plates on the floor, some are off and some are on, and i want to do something when all of them are blue (like display congratulations, or open a door). Please explain me why my logic is wrong, why it doesn’t work that way?

I think you should use a int variable to count something, and cast a bool to int will always be 1.

First get a reference to ALL of the other tiles. You could do this by making an array that is editable and filling it in one by one manually.

Or creating the array by getting the get all actors of class (tile puzzle class here).

Once you have an array of tiles. When you step on the switch it turns the tiles isOn? value to true. Then you want to use a ForEachWithBreak function. Then go through each tile in the array of tiles to check if their isOn bool is true. If its true, increment a int variable called, for the sake of this example, number of tiles on. If its false, then break, because if one is off, the puzzle is not completed and we don’t need to waste time looking at the rest.

Then once the ForEach loop is completed, use a branch node and compare the number of tiles on to see if it equals the length of the array of tiles. IF its true, then the puzzle is solved and all the tiles are on.

I don’t know how to make an editable array, thats what I’ve done:

Is it somewhat right?

Thanks for the replies.

That could work, but where is this array located?

I don’t know, what I have to do to locate an array?